0028. Table

Input file name: table.in
Output file name: table.out
Time limit: 2 s
Memory limit: 64 megabytes

The teacher has written a rectangular table m*n on the blackboard before lesson. But Vasya cleaned the table. There were left only sums by columns and by rows calculated by teacher. The teacher punished Vasya and said that he will not go home until he recovers the table. Help Vasya!

Input file

The starting line of the input file contains two numbers: m is the number of columns and n is the number of rows. Both m and n will not be greater than 100. The second line contains m values of sums for each column, the third one contains sums for rows. All numbers are non-negative integers and their total sum does not exceed 2.1⋅ 109.

Output file

Write n lines with m non-negative integer numbers separated by a single space. If there are more than one solution, output any of them. If there are none, output one string "IMPOSSIBLE".

Examples:

table.intable.out
2 2 2 2 2 2 1 1 1 1


Source: Petrozavodsk training camp, Summer 2002. Startup contest
Author: Andrew Lopatin, Nick Durov

Discuss       Submit a solution



Printable version