import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines sys.setrecursionlimit(10**6) n=int(readline()) d=int(readline()) s=readline().rstrip().decode() def multiply(a, b): l=len(a) m=len(b) c=[0]*(l+m-1) for i, x in enumerate(a): for j, y in enumerate(b): c[i+j]+=x*y return c def add(a, b): l=len(a) m=len(b) c=[0]*(max(l, m)) for i, x in enumerate(a): c[i]+=x for i, x in enumerate(b): c[i]+=x return c i=0 def val(): global i if s[i]=='x': i+=1 return [0, 1] elif s[i]=='d': i+=2 p=expr() i+=1 return [(i+1)*x for i, x in enumerate(p[1:])] else: v=ord(s[i])-ord('0') i+=1 return [v] def mul(): global i res=val() while True: if i==n: break if s[i]=='*': i+=1 p=val() res=multiply(res, p) else: break return res def expr(): global i res=mul() while True: if i==n: break if s[i]=='+': i+=1 p=mul() res=add(res, p) else: break return res p=expr() p+=[0]*(d+1-len(p)) print(' '.join(map(str, p)))