#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, m, q;
struct Matrix {
  int sz;
  vector<vector<int> > a;
  Matrix() {
    sz = 0;
    a.clear();
  }
  Matrix(int _sz, vector<vector<int> > _a) {
    a = _a;
    sz = _sz;
  }
  Matrix(int _sz) {
    sz = _sz;
    vector<int> temp(sz, 0);
    a.assign(sz, temp);
  }
  void print() {
    for (int i = 0; i < sz; i++) {
      for (int j = 0; j < sz; j++) {
        cout << a[i][j] << " ";
      }
      cout << endl;
    }
  }
  Matrix const operator*(Matrix o) {
    Matrix res = Matrix(sz);
    for (int i = 0; i < sz; i++) {
      for (int j = 0; j < sz; j++) {
        int cur = 0;
        for (int k = 0; k < sz; k++) {
          int p = 1ll * a[i][k] * o.a[k][j] % mod;
          cur += p;
          if (cur >= mod) cur -= mod;
        }
        res.a[i][j] = cur;
      }
    }
    return res;
  }
} d, zero, A;
int dx[5] = {0, -1, 1, 0, 0};
int dy[5] = {0, 0, 0, -1, 1};
int a[30][30];
int _x[100100], _y[100100], _type[100100], _t[100100];
Matrix make_matrix() {
  Matrix res = Matrix(n * m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j]) continue;
      for (int d = 0; d < 5; d++) {
        int x = i + dx[d];
        int y = j + dy[d];
        if (x >= 0 && x < n && y >= 0 && y < m) {
          if (a[x][y]) continue;
          res.a[i * m + j][x * m + y]++;
        }
      }
    }
  }
  return res;
}
Matrix binpow(Matrix a, int k) {
  if (k == 0) return zero;
  Matrix ans = binpow(a, k / 2);
  ans = ans * ans;
  if (k % 2) ans = ans * a;
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d%d", _type + i, _x + i, _y + i, _t + i);
    _x[i]--;
    _y[i]--;
  }
  zero = Matrix(n * m);
  for (int i = 0; i < n * m; i++) {
    zero.a[i][i] = 1;
  }
  A = Matrix(n * m);
  A.a[0][0] = 1;
  d = make_matrix();
  int prev_time = 1;
  for (int i = 0; i < q; i++) {
    int x = _x[i], y = _y[i];
    int type = _type[i], t = _t[i];
    int delta = t - prev_time - 1;
    d = make_matrix();
    d = binpow(d, delta);
    A = A * d;
    if (type == 2) a[x][y]++;
    d = make_matrix();
    if (type == 2) {
      for (int dd = 0; dd < 5; dd++) {
        int xx = x + dx[dd];
        int yy = y + dy[dd];
        if (xx >= 0 && xx < n && yy >= 0 && yy < m) {
          if (!a[xx][yy]) {
            int from = x * m + y;
            int to = xx * m + yy;
            d.a[from][to]++;
          }
        }
      }
    } else if (type == 3) {
      for (int dd = 0; dd < 5; dd++) {
        int xx = x + dx[dd];
        int yy = y + dy[dd];
        if (xx >= 0 && xx < n && yy >= 0 && yy < m) {
          if (!a[xx][yy]) {
            int from = x * m + y;
            int to = xx * m + yy;
            d.a[to][from] = 0;
          }
        }
      }
    }
    if (type == 3) a[x][y]--;
    A = A * d;
    if (type == 1) printf("%d\n", A.a[0][x * m + y]);
    prev_time = t;
  }
  return 0;
}
