#include <bits/stdc++.h>
int n, m, i, j, k, flag[25][25], x[4] = {0, 1, 0, -1}, y[4] = {1, 0, -1, 0}, q;
int tmp, a, b, c, d;
struct matrix {
  int n;
  long long a[25][25];
  matrix() { memset(a, 0, sizeof(a)); }
} g, ans;
matrix operator*(const matrix &A, const matrix &B) {
  matrix C;
  C.n = A.n;
  int i, j, k;
  for (i = 1; i <= A.n; i++)
    for (j = 1; j <= A.n; j++)
      for (k = 1; k <= A.n; k++)
        C.a[i][j] = (C.a[i][j] + A.a[i][k] * B.a[k][j]) % 1000000007;
  return C;
}
matrix ksm(matrix g, int x) {
  matrix ans;
  ans.n = n * m;
  if (x == 1) return g;
  ans = ksm(g, x / 2);
  ans = ans * ans;
  if (x & 1) ans = ans * g;
  return ans;
}
int o(int x, int y) { return (x - 1) * m + y; }
void gz() {
  int i, j, k, X, Y;
  for (i = 1; i <= n * m; i++)
    for (j = 1; j <= n * m; j++) g.a[i][j] = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (flag[i][j]) {
        g.a[o(i, j)][o(i, j)] = 1;
        for (k = 0; k < 4; k++) {
          X = i + x[k];
          Y = j + y[k];
          if (flag[X][Y]) g.a[o(i, j)][o(X, Y)] = 1;
        }
      }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  tmp = 1;
  for (i = 1; i <= n * m; i++) ans.a[i][i] = 1;
  ans.n = n * m;
  g.n = n * m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) flag[i][j] = 1;
  for (i = 1; i <= q; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a == 1) {
      gz();
      ans = ans * ksm(g, d - tmp);
      tmp = d;
      printf("%I64d\n", ans.a[o(1, 1)][o(b, c)]);
    } else if (a == 2) {
      gz();
      ans = ans * ksm(g, d - tmp);
      tmp = d;
      flag[b][c] = 0;
    } else {
      gz();
      ans = ans * ksm(g, d - tmp);
      tmp = d;
      flag[b][c] = 1;
    }
  }
}
