#include <bits/stdc++.h>
using namespace std;
using ULL = unsigned long long;
using LL = long long;
using LD = long double;
int n, m, q;
map<pair<int, int>, int> mp;
pair<int, int> shift(pair<int, int> p, int t) {
  pair<int, int> ret;
  ret.first = p.first;
  ret.second = p.second;
  if (t == 1) {
    ret.second = p.second == m ? 1 : p.second + 1;
  } else {
    ret.first = p.first == n ? 1 : p.first + 1;
  }
  return ret;
}
void adjust(int rc, int t) {
  vector<pair<int, int>> k;
  vector<int> v;
  if (t == 1) {
    for (auto it = mp.cbegin(); it != mp.cend();) {
      auto p = *it;
      if (p.first.first == rc) {
        k.push_back(shift(p.first, 1));
        v.push_back(p.second);
        mp.erase(it++);
      } else {
        ++it;
      }
    }
  } else {
    for (auto it = mp.cbegin(); it != mp.cend();) {
      auto p = *it;
      if (p.first.second == rc) {
        k.push_back(shift(p.first, 2));
        v.push_back(p.second);
        mp.erase(it++);
      } else {
        ++it;
      }
    }
  }
  for (int i = 0; i < int((k).size()); i++) {
    mp.insert({{k[i].first, k[i].second}, v[i]});
  }
}
void print() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mp.count({i, j})) {
        cout << mp[{i, j}] << " ";
      } else {
        cout << 0 << " ";
      }
    }
    cout << endl;
  }
}
struct query {
  int t, rc, x, y, val;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> q;
  vector<query> vq;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 1 || t == 2) {
      int rc;
      cin >> rc;
      vq.push_back({t, rc, 0, 0, 0});
    } else {
      int x, y, val;
      cin >> x >> y >> val;
      vq.push_back({t, 0, x, y, val});
    }
  }
  for (int i = q - 1; i >= 0; i--) {
    if (vq[i].t == 1 || vq[i].t == 2) {
      adjust(vq[i].rc, vq[i].t);
    } else {
      mp.insert({{vq[i].x, vq[i].y}, vq[i].val});
    }
  }
  print();
  return 0;
}
