#include <bits/stdc++.h>
using namespace std;
long long int ans[1001][1001], a[1001][1001];
int main() {
  ios::sync_with_stdio(false);
  ;
  cin.tie(0);
  ;
  long long int i, j, n, m, x, y, type, q, id, val, row, col, temp;
  cin >> n >> m >> q;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) a[i][j] = (i - 1) * m + j;
  }
  while (q--) {
    cin >> type;
    if (type == 1) {
      cin >> row;
      temp = a[row][1];
      for (i = 2; i <= m; i++) a[row][i - 1] = a[row][i];
      a[row][m] = temp;
    } else if (type == 2) {
      cin >> col;
      temp = a[1][col];
      for (i = 2; i <= n; i++) a[i - 1][col] = a[i][col];
      a[n][col] = temp;
    } else {
      cin >> row >> col >> val;
      id = a[row][col];
      x = id / m + (id % m != 0);
      y = id % m;
      if (y == 0) y = m;
      ans[x][y] = val;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) cout << ans[i][j] << " ";
    cout << "\n";
  }
  return 0;
}
