Stax

After deciding to move in together, Xorin and Xoranna were faced with yet another problem. Their living room floor is a rectangular shaped grid, divided into n rows and m columns. The height of the room is h. Each square cell contains a stack of cube-shaped boxes. The appearance of the boxes from above and the positions of Xorin and Xoranna are shown in the example below (where n=7, m=5, h=4):

..... X
..... O
..#.. R
.###. A
.##.. N
..... N
..... A
XORIN

Xorin is facing North (towards the Wall). He can see this:

..#..
..##.
.###.
.###.

Xoranna is facing West. She can see this:

..#....
..##...
..##...
..###..

Neither of the two is willing to start unpacking the boxes until they know the exact height of each stack. Your task is to find one possible set of heights that will attest to both their views, and also to the top view of the room.

Input

The first line of the input contains integers n, m, and h.
The rest of the input contains 3 rectangular grids:
  • the first grid has n rows and m columns, and depicts the top view of the room;
  • the second grid has h rows and m columns, and depicts Xorin's view;
  • the third and final grid has h rows and n columns, and depicts Xoranna's view.

Output

The output should contain a grid almost identical to the first input grid. The only difference between the two should be that each # symbol is replaced by a digit, describing the height of the stack located in that particular cell.

Constraints

  • 1 ≤ n, m ≤ 1000
  • 1 ≤ h ≤ 9
  • 1 ≤ any stack's height ≤ h
  • Any output that respects all three perspectives is considered correct.
  • It is guaranteed that at least one valid solution exists.

Sample

InputOutput
7 5 4
.....
.....
..#..
.###.
.##..
.....
.....
..#..
..##.
.###.
.###.
..#....
..##...
..##...
..###..
.....
.....
..1..
.213.
.14..
.....
.....
Questions?

Sponsors Gold