q[][9];n;x;y;i;s;main(c){for(;~scanf("%d%[\n ]",q[x++]+n,&c);c=9)if(c%2582==10?x=!++n:c%8)for(y=++n;n*=!!y;)for(x=n;x;s=!printf("%d%s",s,--x?" ":--y?"\n":&c))for(i=n;i--;)s+=q[i][n-y]*q[n+n-x][i];}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).