Milling machines
A fab lab is an open, small-scale workshop where you can create or fabricate almost anything you want mostly by using computer controlled tools like a laser cutter or a 3D printer. The FAU fab lab recently got a CNC milling machine. Using the milling machine you can cut or remove material with different tools from the surface of a workpiece. It is controlled via a computer program.
I sometimes wondered what happens if multiple different shaped workpieces are sent through the same milling program. For simplification assume that we have only two dimensional workpieces without holes. A milling program consists of multiple steps; each step describes where the milling machine has to remove material (using different tools) from the top of the surface.
Input
The first line consists of two integers and , where gives the number of workpieces and the number of steps in the milling program. The next line consists of two integers and , where gives the width and gives the maximal possible height of workpieces.
Then follow lines, each describing one workpiece. Each workpiece description consists of non-negative integers specifying the surface height in that column.
Then follow lines, each describing one milling step of the milling program. Each milling step description consists of non-negative integers specifying the amount of surface to cut off in each column (relative to the height of the milling area, i.e. , not relative to the top of the workpiece). See Figure for details.
Output
For each workpiece, output one line containing integers specifying the remaining surface heights (in the same order as in the input).
Examples
Second workpiece in first sample: initial workpiece followed by milling in each column — the value in the milling program determines the vertical position of the cutter head.