#include <bits/stdc++.h>
using namespace std;
void getint(int &v) {
  char ch, fu = 0;
  for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') fu = 1, ch = getchar();
  for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0';
  if (fu) v = -v;
}
const int MO = 1e9 + 7;
struct mat {
  int a[20][20];
  mat() { memset(a, 0, sizeof(a)); }
  mat operator*(const mat &A) const {
    mat B;
    for (int i = 0; i <= 19; i++)
      for (int j = 0; j <= 19; j++)
        for (int k = 0; k <= 19; k++)
          (B.a[i][k] += (long long)a[i][j] * A.a[j][k] % MO) %= MO;
    return B;
  }
};
mat pw(mat x, int y) {
  mat t;
  for (int i = 0; i <= 19; i++) t.a[i][i] = 1;
  for (; y; y >>= 1) {
    if (y & 1) t = t * x;
    x = x * x;
  }
  return t;
}
const int dx[] = {-1, 0, 0, 1, 0};
const int dy[] = {0, -1, 1, 0, 0};
int n, m, q, tp, x, y, t, l;
mat A, B;
inline int tra(int x, int y) { return (x - 1) * m + y - 1; }
int main() {
  scanf("%d%d%d", &n, &m, &q);
  l = 1;
  A.a[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int d = 0; d <= 4; d++) {
        int ti = i + dx[d], tj = j + dy[d];
        if (ti < 1 || ti > n || tj < 1 || tj > m) continue;
        B.a[tra(i, j)][tra(ti, tj)] = 1;
      }
  while (q--) {
    getint(tp), getint(x), getint(y), getint(t);
    A = A * pw(B, t - l);
    if (tp == 1)
      printf("%d\n", A.a[0][tra(x, y)]);
    else if (tp == 2) {
      A.a[0][tra(x, y)] = 0;
      for (int d = 0; d <= 4; d++) {
        int tx = x + dx[d], ty = y + dy[d];
        if (tx < 1 || tx > n || ty < 1 || ty > m) continue;
        B.a[tra(tx, ty)][tra(x, y)] = 0;
      }
    } else if (tp == 3) {
      for (int d = 0; d <= 4; d++) {
        int tx = x + dx[d], ty = y + dy[d];
        if (tx < 1 || tx > n || ty < 1 || ty > m) continue;
        B.a[tra(tx, ty)][tra(x, y)] = 1;
      }
    }
    l = t;
  }
  return 0;
}
