| t | """ | t |  | 
            |  |  |  |  | 
            |  | Online Python Compiler. |  |  | 
            |  | Code, Compile, Run and Debug python program online. |  |  | 
            |  | Write your code in this editor and press "Run" button to execute it. |  |  | 
            |  |  |  |  | 
            |  | """ |  |  | 
            |  | import math |  | import math | 
            |  |  |  |  | 
            |  | def get_corners(coords): |  | def get_corners(coords): | 
            |  | (x, y) = coords[:2] |  | (x, y) = coords[:2] | 
            |  | (l, w) = coords[2:-1] |  | (l, w) = coords[2:-1] | 
            |  | if l == 0 or w == 0: |  | if l == 0 or w == 0: | 
            |  | return None |  | return None | 
            |  | else: |  | else: | 
            |  | if l < 0: |  | if l < 0: | 
            |  | lx = x + l |  | lx = x + l | 
            |  | rx = x - 1 |  | rx = x - 1 | 
            |  | elif l > 0: |  | elif l > 0: | 
            |  | lx = x |  | lx = x | 
            |  | rx = x + l - 1 |  | rx = x + l - 1 | 
            |  | if w < 0: |  | if w < 0: | 
            |  | uy = y + w |  | uy = y + w | 
            |  | dy = y - 1 |  | dy = y - 1 | 
            |  | elif w > 0: |  | elif w > 0: | 
            |  | uy = y |  | uy = y | 
            |  | dy = y + w - 1 |  | dy = y + w - 1 | 
            |  | return (lx, dy, rx, uy) |  | return (lx, dy, rx, uy) | 
            |  |  |  |  | 
            |  | def print_matrix(matrix): |  | def print_matrix(matrix): | 
            |  | for i in range(len(matrix)): |  | for i in range(len(matrix)): | 
            |  | for j in range(len(matrix[0])): |  | for j in range(len(matrix[0])): | 
            |  | print(matrix[i][j], end='') |  | print(matrix[i][j], end='') | 
            |  | print('\n') |  | print('\n') | 
            |  |  |  |  | 
            |  | def get_new_coords(bounds, coords): |  | def get_new_coords(bounds, coords): | 
            |  | (lx, dy, rx, uy) = bounds |  | (lx, dy, rx, uy) = bounds | 
            |  | (x, y) = coords[:2] |  | (x, y) = coords[:2] | 
            |  | (l, w) = coords[2:-1] |  | (l, w) = coords[2:-1] | 
            |  | newx = x - lx |  | newx = x - lx | 
            |  | newy = y - uy |  | newy = y - uy | 
            |  | if l < 0: |  | if l < 0: | 
            |  | newx = newx - 1 |  | newx = newx - 1 | 
            |  | if w < 0: |  | if w < 0: | 
            |  | newy = newy - 1 |  | newy = newy - 1 | 
            |  | return (newx, newy) |  | return (newx, newy) | 
            |  |  |  |  | 
            |  | def draw_rects(matrix, rects): |  | def draw_rects(matrix, rects): | 
            |  | for coords in rects: |  | for coords in rects: | 
            |  | (x, y, l, w, s) = coords |  | (x, y, l, w, s) = coords | 
            |  | stepx = 1 if l > 0 else -1 |  | stepx = 1 if l > 0 else -1 | 
            |  | stepy = 1 if w > 0 else -1 |  | stepy = 1 if w > 0 else -1 | 
            |  | for i in range(y, y + w, stepy): |  | for i in range(y, y + w, stepy): | 
            |  | for j in range(x, x + l, stepx): |  | for j in range(x, x + l, stepx): | 
            |  | matrix[i][j] = s |  | matrix[i][j] = s | 
            |  | return matrix |  | return matrix | 
            |  | rects = [] |  | rects = [] | 
            |  | while True: |  | while True: | 
            |  | coords_sym = input() |  | coords_sym = input() | 
            |  | if not coords_sym: |  | if not coords_sym: | 
            |  | break |  | break | 
            |  | else: |  | else: | 
            |  | coords_sym = coords_sym.split(' ') |  | coords_sym = coords_sym.split(' ') | 
            |  | coords_sym = list(map(int, coords_sym[:-1])) + [coords_sym[-1]] |  | coords_sym = list(map(int, coords_sym[:-1])) + [coords_sym[-1]] | 
            |  | rects.append(coords_sym) |  | rects.append(coords_sym) | 
            |  | first = rects[0] |  | first = rects[0] | 
            |  | (lx, dy, rx, uy) = (math.inf, -1 * math.inf, -1 * math.inf, math.inf) |  | (lx, dy, rx, uy) = (math.inf, -1 * math.inf, -1 * math.inf, math.inf) | 
            |  | for coords in rects: |  | for coords in rects: | 
            |  | corners = get_corners(coords) |  | corners = get_corners(coords) | 
            |  | if corners: |  | if corners: | 
            |  | (lx1, dy1, rx1, uy1) = corners |  | (lx1, dy1, rx1, uy1) = corners | 
            |  | if lx1 < lx: |  | if lx1 < lx: | 
            |  | lx = lx1 |  | lx = lx1 | 
            |  | if dy1 > dy: |  | if dy1 > dy: | 
            |  | dy = dy1 |  | dy = dy1 | 
            |  | if rx1 > rx: |  | if rx1 > rx: | 
            |  | rx = rx1 |  | rx = rx1 | 
            |  | if uy1 < uy: |  | if uy1 < uy: | 
            |  | uy = uy1 |  | uy = uy1 | 
            |  | bounds = [lx, dy, rx, uy] |  | bounds = [lx, dy, rx, uy] | 
            |  | matrix = [] |  | matrix = [] | 
            |  | for i in range(uy, dy + 1): |  | for i in range(uy, dy + 1): | 
            |  | row = [] |  | row = [] | 
            |  | for j in range(lx, rx + 1): |  | for j in range(lx, rx + 1): | 
            |  | row.append('.') |  | row.append('.') | 
            |  | matrix.append(row) |  | matrix.append(row) | 
            |  | for coords in rects: |  | for coords in rects: | 
            |  | coords[:2] = get_new_coords(bounds, coords) |  | coords[:2] = get_new_coords(bounds, coords) | 
            |  | matrix = draw_rects(matrix, rects) |  | matrix = draw_rects(matrix, rects) | 
            |  | print_matrix(matrix) |  | print_matrix(matrix) |