#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int n, d; string s; void solve(int& i, vector& a) { a.assign(d+1, 0); long long coefficient = 0; int degree = 0; for(;;){ if(i == n || s[i] == '}'){ a[degree] += coefficient; return; } if(s[i] == 'd'){ i+= 2; vector b; solve(i, b); for(int j=1; j<=d; ++j) a[j-1] += b[j] * j; } else if(s[i] == '+'){ a[degree] += coefficient; coefficient = 0; degree = 0; } else if(s[i] == 'x'){ if(coefficient == 0) coefficient = 1; ++ degree; } else if(isdigit(s[i])){ coefficient *= 10; coefficient += s[i] - '0'; } ++ i; } } int main() { cin >> n >> d >> s; int i = 0; vector a; solve(i, a); cout << a[0]; for(int j=1; j<=d; ++j) cout << ' ' << a[j]; cout << endl; return 0; }