!$0{for(j=M;++j<n;){for(i=0;i<m;)printf S[i++,j] print""}}$0&&(0,0)in S||S[0,0]="#"{for(i in S)O[i]=S[i] M=-1 m||m=n=1 for(r=M;++r<$0&&getline l;)for(w=length(l);w--;)for(i=M;++i<m;)for (j=M;++j<n;)S[i+w*m,j+r*n]=substr(l,w+1,1)~FS?FS:O[i,j] m*=length(l) n*=$0}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).