#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, q, x, r, c;
  cin >> n >> m >> q;
  vector<vector<int>> v(n);
  vector<vector<pair<int, int>>> mm(n);
  for (int i = 0; i < n; ++i) {
    v[i].resize(m);
    mm[i].resize(m);
    for (int j = 0; j < m; ++j) {
      mm[i][j].first = i;
      mm[i][j].second = j;
    }
  }
  while (q-- > 0) {
    cin >> x;
    if (x == 1) {
      cin >> r;
      auto p = mm[r - 1][0];
      for (int j = 1; j < m; ++j) mm[r - 1][j - 1] = mm[r - 1][j];
      mm[r - 1][m - 1] = p;
    } else if (x == 2) {
      cin >> c;
      auto p = mm[0][c - 1];
      for (int i = 1; i < n; ++i) mm[i - 1][c - 1] = mm[i][c - 1];
      mm[n - 1][c - 1] = p;
    } else {
      cin >> r >> c;
      auto& p = mm[r - 1][c - 1];
      cin >> v[p.first][p.second];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (j > 0) cout << ' ';
      cout << v[i][j];
    }
    cout << endl;
  }
  return 0;
}
