<>;$d=<>;$_=<>; s/\*//g; 0while s"d\{(\d*)x(x*)\+?"($1||1)*(1+length$2).$2.'+d{'"e||s"d\{\d*\+?"+"; @a=(0)x($d+1); s"(\d*)(x*)"$a[$2=~y/x//]+=$1||$&&&1"ge; print"@a"