#include <bits/stdc++.h>
using namespace std;
const int MAXN = 20 + 10;
const long long MOD = 1e9 + 7;
const int d[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
inline long long in() {
  long long x = 0, flag = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * flag;
}
struct Matrix {
  int R, C;
  long long val[MAXN][MAXN];
  Matrix() {}
  Matrix(int _R, int _C) { R = _R, C = _C, memset(val, 0, sizeof val); }
  Matrix(int _R, int _C, bool flag) {
    R = _R, C = _C;
    memset(val, 0, sizeof val);
    for (int i = 1; i <= R; ++i) val[i][i] = 1;
  }
  Matrix operator*(const Matrix& B) const {
    Matrix ret(R, B.C);
    for (int i = 1; i <= R; i++)
      for (int j = 1; j <= B.C; j++)
        for (int k = 1; k <= C; k++)
          (ret.val[i][j] += val[i][k] * B.val[k][j] % MOD) %= MOD;
    return ret;
  }
  void print() {
    for (int i = 1; i <= R; ++i, puts(""))
      for (int j = 1; j <= C; printf("%lld ", val[i][j]), ++j)
        ;
  }
} O, G;
Matrix fpow(Matrix A, long long b) {
  if (!b) return A;
  Matrix ret(A.R, A.C, true);
  while (b) {
    if (b & 1)
      ret = ret * A, b ^= 1;
    else
      A = A * A, b >>= 1;
  }
  return ret;
}
int n, m, q;
int pam[MAXN][MAXN];
bool vld[MAXN];
void solve(int t) {
  Matrix ret = fpow(G, t);
  O = O * ret;
}
int main() {
  n = in(), m = in();
  q = in();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) pam[i][j] = (i - 1) * m + j;
  O = Matrix(1, n * m);
  O.val[1][1] = 1LL;
  G = Matrix(n * m, n * m);
  memset(vld, true, sizeof vld);
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= m; y++)
      for (int i = 0; i <= 3; i++) {
        int nx = x + d[i][0], ny = y + d[i][1];
        if (nx >= 1 && nx <= n && ny >= 1 && ny <= m)
          G.val[pam[x][y]][pam[nx][ny]] = 1;
        G.val[pam[x][y]][pam[x][y]] = 1;
      }
  long long pret = 1;
  while (q--) {
    int opt = in(), x = in(), y = in(), t = in();
    int id = pam[x][y];
    if (opt == 1) {
      solve(t - pret);
      printf("%lld\n", O.val[1][id]);
    } else if (opt == 2) {
      solve(t - pret);
      vld[id] = false;
      for (int i = 0; i <= 3; i++) {
        int nx = x + d[i][0], ny = y + d[i][1];
        if (nx >= 1 && nx <= n && ny >= 1 && ny <= m)
          G.val[id][pam[nx][ny]] = G.val[pam[nx][ny]][id] = 0;
      }
      G.val[id][id] = 0;
      O.val[1][id] = 0;
    } else if (opt == 3) {
      solve(t - pret);
      vld[id] = true;
      for (int i = 0; i <= 3; i++) {
        int nx = x + d[i][0], ny = y + d[i][1];
        if (nx >= 1 && nx <= n && ny >= 1 && ny <= m && vld[pam[nx][ny]])
          G.val[id][pam[nx][ny]] = G.val[pam[nx][ny]][id] = 1;
      }
      G.val[id][id] = 1;
    }
    pret = t;
  }
  return 0;
}
