CF641B Little Artem and Matrix
Description
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.
That element can store information about the matrix of integers size $ n×m $ . There are $ n+m $ inputs in that element, i.e. each row and each column can get the signal. When signal comes to the input corresponding to some row, this row cyclically shifts to the left, that is the first element of the row becomes last element, second element becomes first and so on. When signal comes to the input corresponding to some column, that column shifts cyclically to the top, that is first element of the column becomes last element, second element becomes first and so on. Rows are numbered with integers from $ 1 $ to $ n $ from top to bottom, while columns are numbered with integers from $ 1 $ to $ m $ from left to right.
Artem wants to carefully study this element before using it. For that purpose he is going to set up an experiment consisting of $ q $ turns. On each turn he either sends the signal to some input or checks what number is stored at some position of the matrix.
Artem has completed his experiment and has written down the results, but he has lost the chip! Help Artem find any initial matrix that will match the experiment results. It is guaranteed that experiment data is consistent, which means at least one valid matrix exists.
Input Format
The first line of the input contains three integers $ n $ , $ m $ and $ q $ ( $ 1
Output Format
Print the description of any valid initial matrix as $ n $ lines containing $ m $ integers each. All output integers should not exceed $ 10^{9} $ by their absolute value.
If there are multiple valid solutions, output any of them.