class p:
def __init__(self, *args): self.args = args
def __add__(self, other):
if type(other) == int:
res = list(self.args)
res[0] += other
return p(*res)
res = [0]*max(len(self.args), len(other.args))
res[:len(self.args)] = self.args
for i,j in enumerate(other.args):
res[i] += j
return p(*res)
def __mul__(self, other):
res = [0]*(len(self.args)+len(other.args)-1)
for i,x in enumerate(self.args):
for j,y in enumerate(other.args):
res[i+j] += x*y
return p(*res)