#include <bits/stdc++.h>
using namespace std;
const int N = 100;
const int M = 15;
const long long MOD = 1000000007LL;
const double EPS = 1e-8;
int n, m, q;
vector<vector<long long> > has_cat;
void init() {}
long long get_id(long long x, long long y) { return m * x + y; }
vector<pair<long long, long long> > get_conn(int x, int y) {
  int dir[][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {0, 0}};
  vector<pair<long long, long long> > ret;
  for (int i = 0; i < 5; i++) {
    int xx = x + dir[i][0];
    int yy = y + dir[i][1];
    if (xx < 0 || yy < 0 || xx >= n || yy >= m || has_cat[xx][yy]) {
      continue;
    }
    ret.push_back(make_pair(xx, yy));
  }
  return ret;
}
vector<vector<long long> > build_transit() {
  vector<vector<long long> > mat =
      vector<vector<long long> >(n * m, vector<long long>(n * m, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      vector<pair<long long, long long> > conn = get_conn(i, j);
      for (int k = 0; k < conn.size(); k++) {
        int a = get_id(i, j);
        int b = get_id(conn[k].first, conn[k].second);
        mat[a][b] = 1;
      }
    }
  }
  return mat;
}
vector<vector<long long> > multi(vector<vector<long long> > m1,
                                 vector<vector<long long> > m2) {
  int len_n = m1.size(), len_m = m1[0].size();
  vector<vector<long long> > ret =
      vector<vector<long long> >(len_n, vector<long long>(len_m, 0));
  for (int i = 0; i < len_n; i++) {
    for (int j = 0; j < len_m; j++) {
      ret[i][j] = 0;
      for (int k = 0; k < len_m; k++) {
        ret[i][j] += ((m1[i][k] * m2[k][j]) % MOD);
        ret[i][j] %= MOD;
      }
    }
  }
  return ret;
}
vector<vector<long long> > quick_mul(vector<vector<long long> > m1,
                                     vector<vector<long long> > m2, int t) {
  vector<vector<long long> > ma = m1, mb = m2;
  while (t >= 1) {
    if (t & 1) {
      ma = multi(ma, mb);
    }
    t >>= 1;
    mb = multi(mb, mb);
  }
  return ma;
}
vector<vector<long long> > cal(vector<vector<long long> > mat, int t1, int t2) {
  vector<vector<long long> > tran = build_transit();
  return quick_mul(mat, tran, t2 - t1);
}
void solve() {
  has_cat = vector<vector<long long> >(n, vector<long long>(m, 0));
  vector<vector<long long> > mat =
      vector<vector<long long> >(1, vector<long long>(n * m, 0));
  mat[0][0] = 1;
  int cur_time = 1;
  while (q--) {
    int o, x, y, t;
    scanf("%d%d%d%d", &o, &x, &y, &t);
    x--, y--;
    if (o == 1) {
      mat = cal(mat, cur_time, t);
      cout << mat[0][get_id(x, y)] << endl;
    }
    if (o == 2) {
      mat = cal(mat, cur_time, t - 1);
      has_cat[x][y] = 1;
      mat = cal(mat, t - 1, t);
    }
    if (o == 3) {
      mat = cal(mat, cur_time, t);
      has_cat[x][y] = 0;
    }
    cur_time = t;
  }
}
int main() {
  while (cin >> n >> m >> q) {
    init();
    solve();
  }
}
