char g[99][99];p,q,r,s;main(c,x,y){for(;~scanf("%d%d %c",&x,&y,&c);p=!p|p>x?x:p,q=q<x?x:q,r=!r|r>y?y:r,s=s<y?y:s)g[y+=50][x+=50]=c;for(;r<=s;puts(""),++r)for(x=p;x<=q;putchar(c?c:45))c=g[r][x++];}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).