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 = j = 0 inpar = 0 # いくつのd{}に囲まれているか while j < len(s): while s[j] != 43 or inpar > 0: j += 1 if j == len(s): break if s[j] == 123: inpar += 1 if s[j] == 125: inpar -= 1 # 単項式だった場合 if i == 0 and j == len(s): # 微分のとき 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 return res # 項ごとに再計算して次数ごとに係数を合計する ret = cal(s[i:j]) for k in range(d + 1): res[k] += ret[k] i = j = j + 1 return res n = II() d = II() s = SI() s=[ord(c) for c in s] print(*cal(s)) main()