Codeforces Round 348 (VK Cup 2016 Round 2, Div. 2 Edition)
C
Little Artem and Matrix
Codeforces
未评级
原题
← BD →
翻译中…

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

翻译中…

The first line of the input contains three integers $*n*$, $*m*$ and $*q*$ ($1 ≤ *n*, *m* ≤ 100, 1 ≤ *q* ≤ 10 000$) — dimensions of the matrix and the number of turns in the experiment, respectively.

翻译中…

Next $*q*$ lines contain turns descriptions, one per line. Each description starts with an integer $*t*_{*i*}$ ($1 ≤ *t*_{*i*} ≤ 3$) that defines the type of the operation. For the operation of first and second type integer $*r*_{*i*}$ ($1 ≤ *r*_{*i*} ≤ *n*$) or $*c*_{*i*}$ ($1 ≤ *c*_{*i*} ≤ *m*$) follows, while for the operations of the third type three integers $*r*_{*i*}$, $*c*_{*i*}$ and $*x*_{*i*}$ ($1 ≤ *r*_{*i*} ≤ *n*$, $1 ≤ *c*_{*i*} ≤ *m*$, $- 10^{9} ≤ *x*_{*i*} ≤ 10^{9}$) are given.

翻译中…

Operation of the first type ($*t*_{*i*} = 1$) means that signal comes to the input corresponding to row $*r*_{*i*}$, that is it will shift cyclically. Operation of the second type ($*t*_{*i*} = 2$) means that column $*c*_{*i*}$ will shift cyclically. Finally, operation of the third type means that at this moment of time cell located in the row $*r*_{*i*}$ and column $*c*_{*i*}$ stores value $*x*_{*i*}$.

翻译中…

Output

翻译中…

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.

翻译中…

样例

Input #1
2 2 6
2 1
2 2
3 1 1 1
3 2 2 2
3 1 2 8
3 2 1 8
Output #1
8 2
1 8
InputCopy OutputCopy
Input #2
3 3 2
1 2
3 2 2 5
Output #2
0 0 0
0 0 5
0 0 0
InputCopy OutputCopy
题目信息
题号
669C
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。