#include <bits/stdc++.h>
using namespace std;
const int N = 22;
const long long M = 1e9 + 7;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int n, m, q, tp;
class matrix {
 public:
  long long m[N][N];
  matrix() { memset(m, 0, sizeof m); }
  matrix operator*(matrix b) {
    matrix tor;
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        tor.m[i][j] = 0;
        for (int k = 0; k < N; ++k) {
          tor.m[i][j] = (tor.m[i][j] + m[i][k] * b.m[k][j]) % M;
        }
      }
    }
    return tor;
  }
};
matrix ONE;
matrix pow(matrix a, int p) {
  matrix res = ONE;
  for (; p;) {
    if (p & 1) res = res * a;
    a = a * a;
    p >>= 1;
  }
  return res;
}
bool good(int x, int y) { return (x >= 0 && x < n && y >= 0 && y < m); }
matrix edge;
int cat[N][N];
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < N; ++i) {
    ONE.m[i][i] = 1;
  }
  matrix cur;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      edge.m[i * m + j][i * m + j] = 1;
      for (int k = 0; k < 4; ++k) {
        int ni = i + dx[k];
        int nj = j + dy[k];
        if (good(ni, nj)) {
          edge.m[i * m + j][ni * m + nj] = 1;
        }
      }
    }
  }
  cur = ONE;
  int last = 1;
  for (int i = 0; i < q; ++i) {
    int x, y, t;
    scanf("%d%d%d%d", &tp, &x, &y, &t);
    --x;
    --y;
    cur = cur * pow(edge, t - last);
    if (tp == 1) {
      printf("%I64d\n", cur.m[0][x * m + y]);
    }
    if (tp == 2) {
      edge.m[x * m + y][x * m + y] = 0;
      for (int k = 0; k < 4; ++k) {
        int nx = x + dx[k];
        int ny = y + dy[k];
        if (good(nx, ny)) {
          edge.m[x * m + y][nx * m + ny] = 0;
          edge.m[nx * m + ny][x * m + y] = 0;
        }
      }
      cat[x][y] = 1;
    }
    if (tp == 3) {
      edge.m[x * m + y][x * m + y] = 1;
      for (int k = 0; k < 4; ++k) {
        int nx = x + dx[k];
        int ny = y + dy[k];
        if (good(nx, ny) && !cat[nx][ny]) {
          edge.m[x * m + y][nx * m + ny] = 1;
          edge.m[nx * m + ny][x * m + y] = 1;
        }
      }
      cat[x][y] = 0;
    }
    last = t;
  }
  return 0;
}
