#include #include #include #include #include #define FORR(i,b,e) for(int i=(b);i<(int)(e);++i) #define FOR(i,e) FORR(i,0,e) #define ALL(c) begin(c), end(c) #define dump(var) cerr << #var ": " << var << "\n" #define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n" using namespace std; int D; void expr(string &s, int &i, vector &fac); void term(string &s, int &i, vector &fac); void expr(string &s, int &i, vector &fac) { term(s, i, fac); while (s[i] == '+' || s[i] == '-') { i++; term(s, i, fac); } } void term(string &s, int &i, vector &fac) { if (s[i] == 'd') { vector f(D+1); i += 2; expr(s, i, f); i += 1; FORR(d, 1, D+1) { fac[d-1] += d * f[d]; } } else { int c = 1, xd = 0; do { if (isdigit(s[i])) { c = s[i] - '0'; } else if (s[i] == 'x') { xd++; } else break; i++; if (s[i] == '*') i++; } while (i < s.size()); fac[xd] += c; } } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; string S; cin >> N >> D; cin >> S; vector fac(D+1); int i = 0; expr(S, i, fac); cout << fac[0]; FORR(j, 1, D+1) { cout << ' ' << fac[j]; } cout << endl; return 0; }