import java.util.Scanner; public class Yuki265 { long pow(int s, int p) { long tmp = 1; for (int i = s; i <= p; i++) { tmp *= i; } return tmp; } void endTerm(int[] consts, int dimension, int level, long term) { int t = dimension - level; long l = term; if (t < 0) { l *= 0; t = 0; } else { l *= pow(t + 1, dimension); } consts[t] += l; } public Yuki265() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int d = scanner.nextInt(); String S = scanner.next(); long term = 1; int level = 0; int dimension = 0; boolean lastTerm = false; int[] consts = new int[d + 1]; for (int i = 0; i < N; i++) { final char c = S.charAt(i); if (Character.isDigit(c)) { term *= c - '0'; lastTerm = true; } else if (c == 'x') { dimension++; lastTerm = true; } else if (c == '+') { if (lastTerm) { endTerm(consts, dimension, level, term); } term = 1; dimension = 0; } else if (c == 'd') { level++; lastTerm = false; } else if (c == '}') { if (lastTerm) { endTerm(consts, dimension, level, term); } level--; term = 1; // x*d(x) がないので リセットする。 dimension = 0; lastTerm = false; } else if (c == '{') { lastTerm = false; } else if (c == '*') { lastTerm = false; } } if (lastTerm) { endTerm(consts, dimension, level, term); } for (int i = 0; i < d + 1; i++) { if (i > 0) { System.out.print(" "); } System.out.print(consts[i]); } } public static void main(String[] args) { Yuki265 hoge = new Yuki265(); } }