Milling machines#7714

Milling machines

1 secondo
128 megabyte
Facile

A Fab Lab is a small open workshop where you can create or manufacture almost anything you want, mainly using computer-controlled tools such as a laser cutter or a 3D printer. Recently, the FAU Fab Lab acquired a CNC milling machine. With this machine, you can cut or remove material from the surface of a workpiece using various tools. The entire process is controlled by a computer program.

Sometimes I wondered what would happen if several workpieces of different shapes were processed using the same milling program. To simplify the situation, let's assume that we only have two-dimensional workpieces without holes. A milling program consists of several steps, each describing which parts of the surface the milling machine should remove material from (using different tools).

Input

The first line contains two integers and s~(1 \le w, s \le 10^4) — the number of workpieces and the number of steps in the milling program.

The next line contains two integers and y~(1 \le x, y \le 100), where is the width of a workpiece, and is its maximum possible height.

Each of the following lines describes one workpiece. The description of each workpiece consists of non-negative integers defining the surface height in each column.

Then follow lines describing the milling steps. Each milling step consists of non-negative integers s_i~(0 \le s_i \le y), determining how much material should be removed in each column (relative to the milling area height, i.e., relative to , not to the top of the workpiece). See the illustration.

Output

For each workpiece, print one line containing integers — the remaining surface heights after all milling steps (in the same order as in the input).

Esempi

In the first example, you can see how the second workpiece looks after applying all milling steps sequentially: each value in the program defines the vertical position of the milling head.

Esempio 1

Loading
Loading

Esempio 2

Loading
Loading