<>;@a=(0)x(<>+1);$_=<>;y/*//d;s/(x*)(\d)/$2$1/g;s/\bx/1x/g;map{$d=$D+=/d/-/}/;$n=y/d}//c;$d--?$_*=$n:($a[$n]+=$_)until--$n<0}/d|\dx*|}/g;print"@a"