Unit cubes are stacked on an N×M grid. A cell can hold zero or more cubes, and the number of cubes on a cell is the height of that cell.
Three views of the solid are given.
The top view is N rows of M values, each 0 or 1. A cell of height 1 or more is 1, and a cell of height 0 is 0.
The front view is M numbers. The j-th number is the largest height among the cells in column j.
The right side view is N numbers. A viewer standing on the right sees the last row of the top view on the far left, so the k-th number is the largest height among the cells in row N−k+1.
Several height assignments can match all three views. Find the one that uses the most cubes. If such an assignment exists, it is the only one.
Input
The first line has the vertical length N and the horizontal length M, separated by a space. (1≤N,M≤500)
Each of the next N lines has M values, 0 or 1, giving the top view.
The next line has the front view as M integers. Each number is between 0 and 100.
The last line has the right side view as N integers. Each number is between 0 and 100.
Output
Print on N lines the arrangement that matches all three views and uses the most cubes. Each line holds the heights of the M cells in that row, separated by single spaces.
If no arrangement matches the three views, print -1.