def dev(left, right): a = [0 for i in xrange(d)] i = left while i < right: if S[i] == "d": count = 1 for j in xrange(i+2,right): if count == 0: break if S[j] == "{": count += 1 elif S[j] == "}": count -= 1 for k, v in enumerate(dev(i+2,j)): if k > 0: a[k-1] += v*k else: deg = 0 prod = 1 for j in xrange(i,right): if S[j] == "+": break if S[j] == "x": deg += 1 elif S[j].isdigit(): prod = int(S[j]) a[deg] += prod i = j + 1 return a N = int(raw_input()) d = int(raw_input()) + 1 S = list(raw_input()) print " ".join(map(str,dev(0,N)))