beecrowd | 1967

The Final Frontier

By Leandro Zatesko, UFFS BR Brazil

Timelimit: 1

It is the year of 2,265, and the University of the Final Frontier of the Space (UFFS) has already got many campuses around the galaxy, so that all undergraduate courses of UFFS are offered at all campuses. Each course promotes many activities each year, and the activities promoted by a course are the same for all UFFS campuses. In order that every activity can happen, the University needs to buy a certain number of materials, but the prices of each material are not the same for all campuses. A pencil, for example, may cost Ƀ2 (2 bitcoins) for the campus of Chapecó, at planet Earth, and Ƀ7 (7 bitcoins) for the campus of ShiKahr, at planet Vulcan. Despite cost differences, it's never a good idea to buy the materials in a campus to send them to another campus, due to the very high transportation costs and import and export duties. Thus, in order that all the University's activities can be accomplished, the Rectory needs to transfer to each course of each campus the exact amount of bitcoins needed so the courses can buy the materials by themselves.

Input

The first input line consists of four positive integers, G, A, M and C (G ≤ 600; A, C ≤ 100; M ≤ 2000), which represent respectively the number of undergraduate courses, the total number of types of activity that can happen, the total number of types of material that can be needed and the number of UFFS campuses. The courses are designated in the input by the integers from 1 to G, the types of activity by the integers from 1 to A, the types of material by the integers from 1 to M and the campuses by the integers from 1 to C. Then three tables of non-negative integers follow. Each table is preceded by a blank line, between two consecutive columns of a same table there is a column of spaces of width 1, and additional spaces may precede each integer of a table in order to right align all columns of that table, existing at least one integer in a column which is not preceded by additional spaces. The first table consists of G lines, each one containing A integers not greater than 10, so that the jth integer of the ith line represents how many activities of type j an undergraduate course i needs to accomplish in the current year. The second table consists of A lines, each one containing M integers not greater than 10, so that the jth integer of the ith line represents how many materials of type j are needed in order to accomplish an activity of type i. The third and last table consists of M lines, each one containing C integers not greater than 100, so that the jth integer of the ith line represents the price, in bitcoins, of one unit of the material of type i in the planet at which the campus j is located.

Output

Print G lines containing C integers each, so that the jth integer of the ith line represents the amount of bitcoins the Rectory needs to transfer to the course i of the campus j. Follow strictly the same spacing rules between columns of the input.

Input Sample Output Sample

2 3 3 2


1 2 3
3 2 1


2 0 1
0 1 3
2 4 4


  2  7
 11 13
100  3

2070 295
1382 173