#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef vector > VPI; #define ST -1 #define EN -2 char s[50001]; int n, d; int ans[11]; VPI calc(VPI a) { VPI ret; int cnt = 0; for (int p = 0; p < a.size(); p++) { if (a[p].first == ST) { cnt++; }else if (a[p].second == EN) { cnt--; }else { int t = 1; for (int i = 0; i < cnt; i++) { t *= a[p].second; a[p].second--; } ret.emplace_back(a[p].first*t, a[p].second); } } return ret; } VPI henkan(char *s) { VPI ret; int t = 1, b = 0; for (int i = 0; i < n; i++) { if (s[i] == 'd') { t = 1; b = 0; ret.emplace_back(ST, ST); }else if (s[i] == '}') { t = 1; b = 0; ret.emplace_back(EN, EN); } if (isdigit(s[i])) { t *= s[i]-'0'; if ((i+1 < n && s[i+1] != '*') || i+1 >= n) { ret.emplace_back(t, b); t = 1; b = 0; } }else if (s[i] == 'x') { b++; if ((i+1 < n && s[i+1] != '*') || i+1 >= n) { ret.emplace_back(t, b); t = 1; b = 0; } } } return ret; } int main() { scanf("%d", &n); scanf("%d", &d); scanf("%s", s); VPI t = calc(henkan(s)); for (int i = 0; i < t.size(); i++) { ans[t[i].second] += t[i].first; } for (int i = 0; i < d; i++) { printf("%d ", ans[i]); } printf("%d\n", ans[d]); return 0; }