def gf_monic(f, p, K):
 if (not f):
  return (K.zero, [])
 else:
  lc = f[0]
  if K.is_one(lc):
   return (lc, list(f))
  else:
   return (lc, gf_quo_ground(f, lc, p, K))

def gf_monic ( f , p , K ) : if ( not f ) : return ( K . zero , [ ] ) else : lc = f [ 0 ] if K . is_one ( lc ) : return ( lc , list ( f ) ) else : return ( lc , gf_quo_ground ( f , lc , p , K ) )
compute lc and a monic polynomial in gf(p)[x] .