def _dup_rr_trivial_gcd(f, g, K):
 if (not (f or g)):
  return ([], [], [])
 elif (not f):
  if K.is_nonnegative(dup_LC(g, K)):
   return (g, [], [K.one])
  else:
   return (dup_neg(g, K), [], [(- K.one)])
 elif (not g):
  if K.is_nonnegative(dup_LC(f, K)):
   return (f, [K.one], [])
  else:
   return (dup_neg(f, K), [(- K.one)], [])
 return None

def _dup_rr_trivial_gcd ( f , g , K ) : if ( not ( f or g ) ) : return ( [ ] , [ ] , [ ] ) elif ( not f ) : if K . is_nonnegative ( dup_LC ( g , K ) ) : return ( g , [ ] , [ K . one ] ) else : return ( dup_neg ( g , K ) , [ ] , [ ( - K . one ) ] ) elif ( not g ) : if K . is_nonnegative ( dup_LC ( f , K ) ) : return ( f , [ K . one ] , [ ] ) else : return ( dup_neg ( f , K ) , [ ( - K . one ) ] , [ ] ) return None
handle trivial cases in gcd algorithm over a ring .