def f(l):[p,q,c]=l.split();return[int(p),int(q),c] e=list(map(f,open(0))) x=[r[0]for r in e] y=[r[1]for r in e] a,b,c,d=min(x),min(y),max(x)+1,max(y)+1 g={(r[0],r[1]):r[2]for r in e} for i in range(b,d): for j in range(a,c): print(g.get((j,i),'-'),end='') print()
Note that non-ascii characters in the above source code will be escaped (such as \x9f).