#define _USE_MATH_DEFINES #include #include #include #include #include #include //#include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< ///////// typedef long long LL; typedef long double LD; ///////// using namespace::std; ///////// //vector> void bbb(string s,int n,vector> * ans){ vector> temp; /*rep(i,12){ ans[i]=0; temp[i]=0; }*/ LL ter=0; int X=0; for(int i = n;i>::iterator itr = temp.begin(); LL t[12]; for(int asd=0;asd<12;++asd)t[asd]=0; for( ;itr != temp.end();++itr ){ if(itr->second == -1){ i = itr->first; }else{ t[itr->second] += itr->first; } } itr = ans->begin(); for( ;itr != ans->end();++itr ){ t[itr->second] += itr->first; } ans->clear(); for(int asd=0;asd<=10;++asd){ ans->push_back(pair(t[asd],asd)); } temp.clear(); /*for(int j=0;j<=10;++j){ ans[j] += temp[j]; temp[j] = 0; }*/ }else if( s[i] =='+'){ if(X>0){ if( ter == 0){ ans->push_back(pair(1,X)); //ans[X] += 1; }else{ ans->push_back(pair(ter,X)); //ans[X] += ter; //ter = 0; } X = 0; }else{ ans->push_back(pair(ter,0)); //ans[0] += ter; } ter = 0; }else if( s[i] == 'x'){ ++X; }else if( s[i] == '*'){ }else if( s[i] == '{'){ }else if( s[i] == '}'){ if(X>0){ if( ter == 0){ ans->push_back(pair(1,X)); //ans[X] += 1; }else{ ans->push_back(pair(ter,X)); //ans[X] += ter; //ter = 0; } X = 0; }else{ ans->push_back(pair(ter,0)); //ans[0] += ter; } ter = 0; vector>::iterator itr = ans->begin(); for( ;itr != ans->end();++itr ){ if( itr->second > 0){ itr->first = itr->first * (itr->second ); itr->second -= 1; }else{ itr->first = 0; itr->second = 0; } } ans->push_back(pair(i,-1)); //ans[11] = i; return ; }else{ if(ter != 0){ ter = ter * (s[i] - '0'); }else{ ter = s[i] - '0'; } } } if(X>0){ if( ter == 0){ ans->push_back(pair(1,X)); //ans[X] += 1; }else{ ans->push_back(pair(ter,X)); //ans[X] += ter; //ter = 0; } X = 0; }else{ ans->push_back(pair(ter,0)); //ans[0] += ter; } ter = 0; return ; } int main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;// //cout << setprecision(16);// int N,d; string s; cin>>N>>d>>s; vector> ans; bbb(s,0,&ans); vector>::iterator itr = ans.begin(); LL temp[11]; rep(i,11)temp[i] = 0; for(; itr != ans.end();++itr ){ temp[itr->second] += itr->first; } for(int i=0;i<=d;++i){ cout << temp[i]; if(i != d){ cout << " "; }else{ cout << endl; } } return 0; }