#include <bits/stdc++.h>
using namespace std;
const int N = 1e3;
int n, m, q;
int v[N][N];
int ans[N * N];
int main() {
  cin >> n >> m >> q;
  int k = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      v[i][j] = k++;
    }
  }
  for (int qq = 0; qq < q; ++qq) {
    int t, r;
    cin >> t >> r;
    if (t == 1) {
      for (int j = 0; j < m; ++j) v[r][j] = v[r][j + 1];
      v[r][m] = v[r][0];
    } else if (t == 2) {
      for (int i = 0; i < n; ++i) v[i][r] = v[i + 1][r];
      v[n][r] = v[0][r];
    } else {
      int c, x;
      cin >> c >> x;
      ans[v[r][c]] = x;
    }
  }
  k = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cout << ans[k++] << ' ';
    }
    cout << endl;
  }
}
