package tmp; import java.util.Scanner; public class Main { static Scanner sc; public static void main(String[] args) { sc = new Scanner(System.in); solve(); } static long[] ans; static void cast(int D,int d,long num){ for(int j = D;j > 0;j--){ num *= d; d--; } if(d < 0)return; ans[d] += num; } static void solve(){ String s; int n; int l = sc.nextInt(); n = sc.nextInt(); n++; s = sc.next(); ans = new long[n]; int D = 0; for(int i = 0;i < l;i++){ if(i < l-1 && s.substring(i,i+2).equals("d{")){ D++;i++;continue; } if(i < l && s.substring(i,i+1).equals("}")){ D--; continue; } int d = 0; int num = 1; while(true){ String c = s.substring(i,i+1); if(c.equals("d")){ i--; break; } if(c.equals("+")){ i++; continue; } if(c.equals("x")){ d++; }else{ num *= Integer.parseInt(c); } if(i == s.length()-1 || s.substring(i+1,i+2).equals("}")){ cast(D,d,num); break; } c = s.substring(i + 1,i + 2); if(c.equals("*")){ i += 2; } if(c.equals("+")){ cast(D,d,num); i++; break; } } } for(int j = 0;j < n;j++){ System.out.print(ans[j]); System.out.print(" "); } System.out.println(); } }