import sys sys.setrecursionlimit(10 ** 6) def II(): return int(sys.stdin.readline()) def SI(): return sys.stdin.readline()[:-1] def main(): def cal(s): res = [0] * (d + 1) i = 0 inpar = 0 # いくつのd{}に囲まれているか isone=True # 単項式かどうか for j,c in enumerate(s): if c==43 and inpar==0: ret = cal(s[i:j]) for k in range(d + 1): res[k] += ret[k] i = j + 1 isone=False if c == 123: inpar += 1 if c == 125: inpar -= 1 if isone: # 微分のとき if s[0] == 100: ret = cal(s[2:-1]) for i, a in enumerate(ret[1:], 1): res[i - 1] = a * i # 累乗の計算のとき else: a = 1 x = 0 for c in s: if 48 <= c <= 57: a = c - 48 if c == 120: x += 1 res[x] = a else: ret = cal(s[i:]) for k in range(d + 1): res[k] += ret[k] return res n = II() d = II() s = SI() s=[ord(c) for c in s] print(*cal(s)) main()