# 50022. Matrix

## Problem Description

There is a $m$ by $n$ matrix consisting of integers from 1 to $mn$. You are given the sum of the rows and the sums of the columns, and please write a program to determine the number in each cell of the matrix. Consider the following example.

R\C 1 2 3 4 $R\lbrack ]$
1 1 2 3 4 10
2 5 6 7 8 26
3 9 10 11 12 42
$C\lbrack ]$ 15 18 21 24 none

Now you are given $m = 3$, $n = 4$, and $10$, $26$, and $42$ as the sums of rows, and $15$, $18$, $21$ and $24$ as the sums of columns. The locations of all numbers will be as above. Your task is to print the numbers as a $m$ by $n$ matrix. If there are no solutions, print no solution.

• 10pt. $n = 1$ or $m = 1$.
• 15pt. $m = n = 2$, and there is exacly one solution.
• 15pt. $m = n = 2$. and there could be no solution.
• 50pt. $m \times n \le 12$, and there could be no solution.
• 10pt. $m \times n \le 16$, and there could be no solution.

## Sample Input

1 361 2 32 11 233 26 6 96 154 410 26 42 5828 32 36 40


## Sample Output

1 2 3121 52 43 61 2 3 45 6 7 89 10 11 1213 14 15 16