#include <bits/stdc++.h>
using namespace std;
typedef struct data {
  int r, c, n;
} cell;
cell a[101][101];
vector<cell> b;
bool comp(const data &p, const data &q) {
  if (p.r == q.r)
    return p.c < q.c;
  else
    return p.r < q.r;
}
int main() {
  int tc, cs = 1;
  int n, m, q, t, x, y, z;
  while (cin >> n >> m >> q) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        a[i][j].r = i;
        a[i][j].c = j;
        a[i][j].n = 0;
      }
    }
    for (int i = 0; i < q; i++) {
      cin >> t;
      if (t == 1) {
        cin >> x;
        x--;
        cell tmp;
        tmp.r = a[x][0].r;
        tmp.c = a[x][0].c;
        tmp.n = a[x][0].n;
        for (int i = 0; i < m; i++) {
          if (i == m - 1)
            swap(a[x][m - 1], tmp);
          else
            a[x][i] = a[x][i + 1];
        }
      } else if (t == 2) {
        cin >> y;
        y--;
        cell tmp;
        tmp.r = a[0][y].r;
        tmp.c = a[0][y].c;
        tmp.n = a[0][y].n;
        for (int i = 0; i < n; i++) {
          if (i == n - 1)
            swap(a[n - 1][y], tmp);
          else
            a[i][y] = a[i + 1][y];
        }
      } else {
        cin >> x >> y >> z;
        x--, y--;
        a[x][y].n = z;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        b.push_back(a[i][j]);
      }
    }
    sort(b.begin(), b.end(), comp);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int cur = i * m + j;
        cout << b[cur].n << " ";
      }
      cout << "\n";
    }
    b.clear();
  }
  return 0;
}
