#include <bits/stdc++.h>
using namespace std;
int n, m, q, b[22][22], pre;
struct Matrix {
  int a[22][22];
} a, ans, tmp;
Matrix buildm() {
  Matrix ret;
  for (int p = 1; p <= n * m; p++)
    for (int q = 1; q <= n * m; q++) {
      int px = (p - 1) / m + 1, py = p - m * (px - 1);
      int qx = (q - 1) / m + 1, qy = q - m * (qx - 1);
      if (b[px][py] || b[qx][qy]) {
        ret.a[p][q] = 0;
        continue;
      }
      if (abs(px - qx) + abs(py - qy) <= 1)
        ret.a[p][q] = 1;
      else
        ret.a[p][q] = 0;
    }
  return ret;
}
Matrix cheng(Matrix a, Matrix b) {
  Matrix ret;
  memset(ret.a, 0, sizeof(ret.a));
  for (int i = 1; i <= n * m; i++)
    for (int k = 1; k <= n * m; k++)
      if (a.a[i][k])
        for (int j = 1; j <= n * m; j++)
          (ret.a[i][j] += ((long long)a.a[i][k] * b.a[k][j]) % 1000000007) %=
              1000000007;
  return ret;
}
Matrix mypow(Matrix a, int k) {
  Matrix ret;
  memset(ret.a, 0, sizeof(ret.a));
  for (int i = 1; i <= n * m; i++) ret.a[i][i] = 1;
  while (k) {
    if (k & 1) ret = cheng(ret, a);
    a = cheng(a, a);
    k >>= 1;
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  ans.a[1][1] = 1;
  pre = 1;
  for (int i = 1; i <= q; i++) {
    int tp, x, y, t;
    scanf("%d%d%d%d", &tp, &x, &y, &t);
    if (tp == 2) {
      int tt = t - pre - 1;
      Matrix la = buildm();
      la = mypow(la, tt);
      ans = cheng(ans, la);
      memset(tmp.a, 0, sizeof(tmp.a));
      for (int q = 1; q <= n * m; q++) {
        int qx = (q - 1) / m + 1, qy = q - m * (qx - 1);
        if (b[qx][qy] || (qx == x && qy == y)) continue;
        tmp.a[1][q] = ans.a[1][q];
        if (qx - 1 > 0 && b[qx - 1][qy] == 0)
          (tmp.a[1][q] += ans.a[1][(qx - 2) * m + qy]) %= 1000000007;
        if (qy - 1 > 0 && b[qx][qy - 1] == 0)
          (tmp.a[1][q] += ans.a[1][(qx - 1) * m + qy - 1]) %= 1000000007;
        if (qx + 1 <= n && b[qx + 1][qy] == 0)
          (tmp.a[1][q] += ans.a[1][qx * m + qy]) %= 1000000007;
        if (qy + 1 <= m && b[qx][qy + 1] == 0)
          (tmp.a[1][q] += ans.a[1][(qx - 1) * m + qy + 1]) %= 1000000007;
      }
      ans = tmp;
      b[x][y] = 1;
      pre = t;
    }
    if (tp == 3) {
      int tt = t - pre - 1;
      Matrix la = buildm();
      la = mypow(la, tt);
      ans = cheng(ans, la);
      memset(tmp.a, 0, sizeof(tmp.a));
      b[x][y] = 0;
      for (int q = 1; q <= n * m; q++) {
        int qx = (q - 1) / m + 1, qy = q - m * (qx - 1);
        if (b[qx][qy] || (qx == x && qy == y)) continue;
        tmp.a[1][q] = ans.a[1][q];
        if (qx - 1 > 0 && b[qx - 1][qy] == 0)
          (tmp.a[1][q] += ans.a[1][(qx - 2) * m + qy]) %= 1000000007;
        if (qy - 1 > 0 && b[qx][qy - 1] == 0)
          (tmp.a[1][q] += ans.a[1][(qx - 1) * m + qy - 1]) %= 1000000007;
        if (qx + 1 <= n && b[qx + 1][qy] == 0)
          (tmp.a[1][q] += ans.a[1][qx * m + qy]) %= 1000000007;
        if (qy + 1 <= m && b[qx][qy + 1] == 0)
          (tmp.a[1][q] += ans.a[1][(qx - 1) * m + qy + 1]) %= 1000000007;
      }
      ans = tmp;
      pre = t;
    }
    if (tp == 1) {
      int tt = t - pre;
      Matrix la = buildm();
      la = mypow(la, tt);
      ans = cheng(ans, la);
      printf("%d\n", ans.a[1][(x - 1) * m + y]);
      pre = t;
    }
  }
  return 0;
}
