def sdm_add(f, g, O, K):
 h = dict(f)
 for (monom, c) in g:
  if (monom in h):
   coeff = (h[monom] + c)
   if (not coeff):
    del h[monom]
   else:
    h[monom] = coeff
  else:
   h[monom] = c
 return sdm_from_dict(h, O)

def sdm_add ( f , g , O , K ) : h = dict ( f ) for ( monom , c ) in g : if ( monom in h ) : coeff = ( h [ monom ] + c ) if ( not coeff ) : del h [ monom ] else : h [ monom ] = coeff else : h [ monom ] = c return sdm_from_dict ( h , O )
add two module elements f .