This page is still under construction.

Parts of this page are still being built. What you see may change.

Crossword puzzle decoration

Time limit1sMemory limit128 MB

Summary
Surround the M by N letter grid with the given padding and fill the added cells with alternating # and . by row plus column parity.
Level

Easy1 of 10

Topics
Implementation, Matrix
Solved
No attempts yet

Problem

Changyeong likes crossword puzzles. He has solved every puzzle in the world, so now he wants to decorate one.

A puzzle is a grid of M×NM \times N letters. Changyeong adds UU rows above the puzzle, LL columns to its left, RR columns to its right, and DD rows below it. The finished decoration is a rectangle with U+M+DU + M + D rows and L+N+RL + N + R columns.

The added cells are filled with # and . so that they alternate like a chessboard. Let (i,j)(i, j) be the cell in row ii from the top and column jj from the left of the finished rectangle. A cell with i+ji + j even holds #, and a cell with i+ji + j odd holds .. The top left cell (1,1)(1, 1) is therefore #. Cells that the original puzzle occupies keep their letters.

Input

The first line contains MM and NN. (1≤M,N≤101 \le M, N \le 10)

The second line contains UU, LL, RR, and DD. (0≤U,L,R,D≤50 \le U, L, R, D \le 5)

Each of the next MM lines contains NN letters of the crossword puzzle.

Output

Print the decorated crossword puzzle on U+M+DU + M + D lines. Each line has L+N+RL + N + R characters.

Examples2

  1. Example 1

    Input
    4 4
    2 2 2 2
    honi
    oker
    nera
    irak
    
    Expected output
    #.#.#.#.
    .#.#.#.#
    #.honi#.
    .#oker.#
    #.nera#.
    .#irak.#
    #.#.#.#.
    .#.#.#.#
    
  2. Example 2

    Input
    2 4
    1 0 3 1
    rima
    mama
    
    Expected output
    #.#.#.#
    rima.#.
    mama#.#
    .#.#.#.