#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
struct matrix {
  int t[20 + 1][20 + 1];
};
int r, c, q;
bool inside(int x, int y) { return (x >= 1 && x <= r && y >= 1 && y <= c); }
int dx[] = {0, 0, 1, -1, 0};
int dy[] = {1, -1, 0, 0, 0};
matrix muti(const matrix &A, const matrix &B, int m, int n) {
  matrix C;
  memset(C.t, 0, sizeof C.t);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        C.t[i][j] = (1ll * A.t[i][k] * B.t[k][j] + C.t[i][j]) % mod;
  return C;
}
matrix show(matrix A) {
  for (int i = 1; i <= r * c; i++) {
    for (int j = 1; j <= r * c; j++) printf("%d ", A.t[i][j]);
    printf("\n");
  }
  printf("----\n");
}
matrix start, curr, mul;
int last = 1;
void goNext(int t) {
  int k = t - last;
  matrix B = mul;
  while (k > 0) {
    if (k % 2) curr = muti(curr, B, 1, r * c);
    B = muti(B, B, r * c, r * c);
    k /= 2;
  }
  last = t;
}
void input() {
  scanf("%d %d %d", &r, &c, &q);
  for (int x = 1; x <= r; x++)
    for (int y = 1; y <= c; y++)
      for (int k = 0; k < 5; k++) {
        int cx = x + dx[k];
        int cy = y + dy[k];
        if (inside(cx, cy)) start.t[(x - 1) * c + y][(cx - 1) * c + cy] = 1;
      }
  mul = start;
  curr.t[1][1] = 1;
  while (q > 0) {
    int tp, x, y, t;
    scanf("%d %d %d %d", &tp, &x, &y, &t);
    goNext(t - 1);
    if (tp == 2) {
      goNext(t - 1);
      for (int i = 1; i <= r * c; i++) mul.t[i][(x - 1) * c + y] = 0;
    } else if (tp == 3) {
      goNext(t);
      for (int i = 1; i <= r * c; i++)
        mul.t[i][(x - 1) * c + y] = start.t[i][(x - 1) * c + y];
    }
    goNext(t);
    if (tp == 1) printf("%d\n", curr.t[1][(x - 1) * c + y]);
    q--;
  }
}
int main() { input(); }
