def gf_compose(f, g, p, K):
 if (len(g) <= 1):
  return gf_strip([gf_eval(f, gf_LC(g, K), p, K)])
 if (not f):
  return []
 h = [f[0]]
 for c in f[1:]:
  h = gf_mul(h, g, p, K)
  h = gf_add_ground(h, c, p, K)
 return h

def gf_compose ( f , g , p , K ) : if ( len ( g ) <= 1 ) : return gf_strip ( [ gf_eval ( f , gf_LC ( g , K ) , p , K ) ] ) if ( not f ) : return [ ] h = [ f [ 0 ] ] for c in f [ 1 : ] : h = gf_mul ( h , g , p , K ) h = gf_add_ground ( h , c , p , K ) return h
compute polynomial composition f(g) in gf(p)[x] .