Milling machines

No attempts yetTime limit2sMemory limit256 MB

Problem

A fab lab is a small open workshop where you can make almost anything yourself with computer controlled tools such as a laser cutter or a 3D printer. One fab lab recently got a CNC milling machine. The machine removes material from the surface of a workpiece with different tools, and a computer program drives it.

Suppose workpieces of different shapes are sent through the same milling program one after another. To keep things simple, a workpiece is a two dimensional shape without holes: it is XX columns wide, and each column has one surface height.

A milling program consists of several steps. Each step states how deep the cutter head goes in each column. If the ii-th value of a step is sis_i, then during that step the cutter head for column ii sits at height YsiY - s_i, and whatever rises above YsiY - s_i in that column is cut away. The cut depth is measured from the height YY of the milling area, not from the current surface of the workpiece.

Apply all steps in order and report the surface heights that remain on each workpiece.

Input

The first line contains the number of workpieces WW and the number of steps SS in the milling program (1W,S1041 \le W, S \le 10^4).

The second line contains the width XX of the workpieces and the maximal possible height YY of a workpiece (1X,Y1001 \le X, Y \le 100).

The next WW lines describe one workpiece each. Every line holds XX non-negative integers, where the ii-th value is the surface height of column ii. Each height is between 0 and YY.

The next SS lines describe one milling step each, in order. Every line holds XX non-negative integers sis_i with 0siY0 \le s_i \le Y, giving the amount cut off in that column relative to the height YY of the milling area.

Output

For each workpiece, print one line with the XX remaining surface heights, separated by single spaces and in the same order as in the input.

Figure: the second workpiece of the first example. The initial workpiece is followed by the milling of each column. The value in the milling program sets the vertical position of the cutter head.