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 int i; static String s; static int n; static int[] scan(){ int d[] = new int[n]; for(int j = 0;j < n;j++)d[j] = 0; int tn = 0; int tv = 0; while(true){ String nx; if(i < s.length()){ nx = s.substring(i, i + 1) ; }else{ nx = "end"; } if(nx.equals("x")){ if(tv == 0)tv = 1; tn++; }else if(nx.equals("*")){ }else if(nx.equals("}") || nx.equals("end") || nx.equals("+")){ d[tn] += tv; tn = 0; tv = 0; if(nx.equals("}"))break; }else if(i < s.length()-1 && s.substring(i, i + 2).equals("d{")){ i += 2; int tmp[] = scan(); for(int j = 1;j < n;j++){ d[j-1] += tmp[j] * j; } }else { if(tv == 0)tv = 1; tv *= Integer.parseInt(nx); } i++; if(nx.equals("end"))break; } return d; } static void solve(){ int l = sc.nextInt(); n = sc.nextInt(); n++; s = sc.next(); int[] d = new int[n]; i = 0; d = scan(); for(int j = 0;j < n;j++){ System.out.print(d[j]); System.out.print(" "); } System.out.println(); } }