| n | buf = [] | n | mas = [] | 
            |  | (minx, miny, maxx, maxy) = (0, 0, 0, 0) |  | (minx, miny, maxx, maxy) = (0, 0, 0, 0) | 
            |  | while (s := input()): |  | while (s := input()): | 
            | t | tmp = list(map(int, s.split()[:-1])) | t | cor = list(map(int, s.split()[:-1])) | 
            |  | if tmp[2] != 0 and tmp[3] != 0: |  | if cor[2] != 0 and cor[3] != 0: | 
            |  | if tmp[2] < 0: |  | if cor[2] < 0: | 
            |  | tmp[0] += tmp[2] |  | cor[0] += cor[2] | 
            |  | tmp[2] = 0 - tmp[2] |  | cor[2] = 0 - cor[2] | 
            |  | if tmp[3] < 0: |  | if cor[3] < 0: | 
            |  | tmp[1] += tmp[3] |  | cor[1] += cor[3] | 
            |  | tmp[3] = 0 - tmp[3] |  | cor[3] = 0 - cor[3] | 
            |  | maxx = max(maxx, tmp[0] + tmp[2]) |  | maxx = max(maxx, cor[0] + cor[2]) | 
            |  | maxy = max(maxy, tmp[1] + tmp[3]) |  | maxy = max(maxy, cor[1] + cor[3]) | 
            |  | buf.append((tmp, s.split()[-1])) |  | mas.append((cor, s.split()[-1])) | 
            |  | minx = min((i[0][0] for i in buf)) |  | minx = min((i[0][0] for i in mas)) | 
            |  | miny = min((i[0][1] for i in buf)) |  | miny = min((i[0][1] for i in mas)) | 
            |  | ans = [['.' for i in range(maxx - minx)] for j in range(maxy - miny)] |  | image = [['.' for i in range(maxx - minx)] for j in range(maxy - miny)] | 
            |  | for i in buf: |  |  | 
            |  | tmp = i[0] |  |  | 
            |  | for j in range(tmp[1] - miny, tmp[1] - miny + tmp[3]): |  |  | 
            |  | for k in range(tmp[0] - minx, tmp[0] - minx + tmp[2]): |  |  | 
            |  | ans[j][k] = i[1] |  |  | 
            |  | for i in ans: |  | for i in mas: | 
            |  |  |  | cor = i[0] | 
            |  |  |  | for j in range(cor[1] - miny, cor[1] - miny + cor[3]): | 
            |  |  |  | for k in range(cor[0] - minx, cor[0] - minx + cor[2]): | 
            |  |  |  | image[j][k] = i[1] | 
            |  |  |  | for i in image: | 
            |  | print(*i, sep='') |  | print(*i, sep='') |