# Little Artem and Matrix

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 nm 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 ic i and x i (1 ≤ r i ≤ n, 1 ≤ c i ≤ m,  - 109 ≤ x i ≤ 109) 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 109 by their absolute value.

If there are multiple valid solutions, output any of them.

Examples

input

2 2 62 12 23 1 1 13 2 2 23 1 2 83 2 1 8

output

8 2 1 8

input

3 3 21 23 2 2 5

output

0 0 0 0 0 5 0 0 0

Solution:

#include <bits/stdc++.h>

using namespace std;

const int N = 777;

int res[N][N];
pair <int, int> a[N][N];

int main() {
int n, m, q;
scanf("%d %d %d", &n, &m, &q);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][j] = make_pair(i, j);
res[i][j] = 0;
}
}
for (int it = 0; it < q; it++) {
int type;
scanf("%d", &type);
if (type == 1) {
int r;
scanf("%d", &r);
r--;
pair <int, int> tmp = a[r][0];
for (int j = 1; j < m; j++) {
a[r][j - 1] = a[r][j];
}
a[r][m - 1] = tmp;
}
if (type == 2) {
int c;
scanf("%d", &c);
c--;
pair <int, int> tmp = a[0];
for (int j = 1; j < n; j++) {
a[j - 1] = a[j];
}
a[n - 1] = tmp;
}
if (type == 3) {
int i, j, x;
scanf("%d %d %d", &i, &j, &x);
i--; j--;
res[a[i][j].first][a[i][j].second] = x;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (j > 0) putchar(' ');
printf("%d", res[i][j]);
}
printf("\n");
}
return 0;
}