def gf_cofactors(f, g, p, K):
 if ((not f) and (not g)):
  return ([], [], [])
 h = gf_gcd(f, g, p, K)
 return (h, gf_quo(f, h, p, K), gf_quo(g, h, p, K))

def gf_cofactors ( f , g , p , K ) : if ( ( not f ) and ( not g ) ) : return ( [ ] , [ ] , [ ] ) h = gf_gcd ( f , g , p , K ) return ( h , gf_quo ( f , h , p , K ) , gf_quo ( g , h , p , K ) )
compute polynomial gcd and cofactors in gf(p)[x] .