def gf_add_ground(f, a, p, K):
 if (not f):
  a = (a % p)
 else:
  a = ((f[(-1)] + a) % p)
  if (len(f) > 1):
   return (f[:(-1)] + [a])
 if (not a):
  return []
 else:
  return [a]

def gf_add_ground ( f , a , p , K ) : if ( not f ) : a = ( a % p ) else : a = ( ( f [ ( - 1 ) ] + a ) % p ) if ( len ( f ) > 1 ) : return ( f [ : ( - 1 ) ] + [ a ] ) if ( not a ) : return [ ] else : return [ a ]
compute f + a where f in gf(p)[x] and a in gf(p) .