#P1153B. Serval and Toy Bricks
Serval and Toy Bricks
No submission language available for this problem.
Description
Luckily, Serval got onto the right bus, and he came to the kindergarten on time. After coming to kindergarten, he found the toy bricks very funny.
He has a special interest to create difficult problems for others to solve. This time, with many toy bricks, he builds up a 3-dimensional object. We can describe this object with a matrix, such that in each cell , there are bricks standing on the top of each other.
However, Serval doesn't give you any , and just give you the front view, left view, and the top view of this object, and he is now asking you to restore the object. Note that in the front view, there are columns, and in the -th of them, the height is the maximum of . It is similar for the left view, where there are columns. And in the top view, there is an matrix , where is or . If equals , that means , otherwise, .
However, Serval is very lonely because others are bored about his unsolvable problems before, and refused to solve this one, although this time he promises there will be at least one object satisfying all the views. As his best friend, can you have a try?
The first line contains three positive space-separated integers () — the length, width and height.
The second line contains non-negative space-separated integers , where is the height in the -th column from left to right of the front view ().
The third line contains non-negative space-separated integers (), where is the height in the -th column from left to right of the left view.
Each of the following lines contains numbers, each is or , representing the top view, where -th number of -th row is if , and otherwise.
It is guaranteed that there is at least one structure satisfying the input.
Output lines, each of them contains integers, the -th number in the -th line should be equal to the height in the corresponding position of the top view. If there are several objects satisfying the views, output any one of them.
Input
The first line contains three positive space-separated integers () — the length, width and height.
The second line contains non-negative space-separated integers , where is the height in the -th column from left to right of the front view ().
The third line contains non-negative space-separated integers (), where is the height in the -th column from left to right of the left view.
Each of the following lines contains numbers, each is or , representing the top view, where -th number of -th row is if , and otherwise.
It is guaranteed that there is at least one structure satisfying the input.
Output
Output lines, each of them contains integers, the -th number in the -th line should be equal to the height in the corresponding position of the top view. If there are several objects satisfying the views, output any one of them.
Samples
Note

The graph above illustrates the object in the first example.


The first graph illustrates the object in the example output for the second example, and the second graph shows the three-view drawing of it.