#include #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int n,d,idx; string s; vector expr(); vector term(){ if(s[idx]=='d'){ idx+=2; auto res=expr(); assert(idx res(d+1); res[deg]=coef; return res; } } vector expr(){ vector res(d+1); if(idx==n) return res; while(1){ auto tmp=term(); rep(i,d+1) res[i]+=tmp[i]; if(idx==n || s[idx]=='}') break; if(s[idx]=='+') idx++; } return res; } int main(){ cin>>n>>d>>s; auto res=expr(); rep(i,d+1) printf("%d%c",res[i],i