#include <bits/stdc++.h>
using namespace std;
int scan() {
  int res = 0, ch;
  while (!((ch = getchar()) >= '0' && ch <= '9')) {
    if (ch == EOF) return 1 << 30;
  }
  res = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9') res = res * 10 + (ch - '0');
  return res;
}
struct is {
  int a, pos;
} a[110][110];
struct gg {
  int ans, pos;
} ans[100010];
int cmp(gg a, gg b) { return a.pos < b.pos; }
int main() {
  int x, y, z, i, t;
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= n; i++)
    for (t = 1; t <= m; t++) a[i][t].pos = (i - 1) * m + t;
  while (q--) {
    int op, h, l, change;
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d", &h);
      is zz = a[h][1];
      for (i = 2; i <= m; i++) a[h][i - 1] = a[h][i];
      a[h][m] = zz;
    } else if (op == 2) {
      scanf("%d", &l);
      is zz = a[1][l];
      for (i = 2; i <= n; i++) a[i - 1][l] = a[i][l];
      a[n][l] = zz;
    } else if (op == 3) {
      scanf("%d%d%d", &h, &l, &change);
      a[h][l].a = change;
    }
  }
  for (i = 1; i <= n; i++)
    for (t = 1; t <= m; t++) {
      ans[(i - 1) * m + t].ans = a[i][t].a;
      ans[(i - 1) * m + t].pos = a[i][t].pos;
    }
  sort(ans + 1, ans + 1 + (n * m), cmp);
  for (i = 1; i <= n; i++)
    for (t = 1; t <= m; t++)
      printf("%d%c", ans[(i - 1) * m + t].ans, t == m ? '\n' : ' ');
  return 0;
}
