def step_2(w):
 for (suffix, rules) in suffixes2:
  if w.endswith(suffix):
   for (A, B) in rules:
    if w.endswith(A):
     return ((R1(w).endswith(A) and (w[:(- len(A))] + B)) or w)
 if (w.endswith('li') and (R1(w)[(-3):(-2)] in VALID_LI)):
  return w[:(-2)]
 return w

def step_2 ( w ) : for ( suffix , rules ) in suffixes2 : if w . endswith ( suffix ) : for ( A , B ) in rules : if w . endswith ( A ) : return ( ( R1 ( w ) . endswith ( A ) and ( w [ : ( - len ( A ) ) ] + B ) ) or w ) if ( w . endswith ( 'li' ) and ( R1 ( w ) [ ( - 3 ) : ( - 2 ) ] in VALID_LI ) ) : return w [ : ( - 2 ) ] return w
step 2 replaces double suffixes .