package no265; import java.math.BigInteger; import java.util.Arrays; import java.util.Scanner; public class Main implements Runnable { public static void main(String[] args) { new Thread(null, new Main(), "", 1024L*1024*16).start();; } public void run() { solve(); } int n,d; char[] s; Polynomial x; public void solve() { Scanner sc = new Scanner(System.in); n = sc.nextInt(); int d2 = sc.nextInt(); d = Math.max(1, d2); s = sc.next().toCharArray(); x = new Polynomial(); x.a[1] = BigInteger.ONE; Polynomial ans = expression(); StringBuilder sb = new StringBuilder(); for(int i=0;i<=d2;i++) { if (i > 0) { sb.append(' '); } sb.append(ans.a[i]); } System.out.println(sb); } int ind = 0; public Polynomial expression() { Polynomial p = term(); while(ind < n) { if (s[ind] != '+') { break; } ind++; p = p.add(term()); } return p; } public Polynomial term() { Polynomial p = number(); while(ind < n) { if (s[ind] != '*') { break; } ind++; p = p.mul(number()); } return p; } public Polynomial number() { Polynomial ret; if (s[ind] == 'd') { ind += 2; ret = expression().diff(); ind++; }else{ if (s[ind] == 'x') { ret = x; ind++; }else{ ret = new Polynomial(BigInteger.valueOf(s[ind] - '0')); ind++; } } return ret; } public class Polynomial { BigInteger[] a = new BigInteger[d+1]; public Polynomial() { Arrays.fill(a, BigInteger.ZERO); } public Polynomial(BigInteger a0) { this(); a[0] = a0; } public Polynomial add(Polynomial q) { Polynomial p = this; Polynomial r = new Polynomial(); for(int i=0;i<=d;i++) { r.a[i] = p.a[i].add(q.a[i]); } return r; } public Polynomial mul(Polynomial q) { Polynomial p = this; Polynomial r = new Polynomial(); for(int i=0;i<=d;i++) { for(int j=0;j<=i;j++) { r.a[i] = r.a[i].add(p.a[j].multiply(q.a[i-j])); } } return r; } public Polynomial diff() { Polynomial q = new Polynomial(); for(int i=0;i