#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long a[25][25], b[25][25], ans[25][25], now[25][25];
int n, m, q;
long long f[2][25];
int bb[25];
int dq, dqt, x, y, t, z;
void mul(long long a[25][25], int x) {
  for (int i = 1; i <= n * m; ++i)
    for (int j = 1; j <= n * m; ++j) b[i][j] = a[i][j];
  for (int i = 1; i <= n * m; ++i)
    for (int j = 1; j <= n * m; ++j) ans[i][j] = 0;
  for (int i = 1; i <= n * m; ++i) ans[i][i] = 1;
  while (x) {
    if (x & 1) {
      memset(now, 0, sizeof(now));
      for (int i = 1; i <= n * m; ++i)
        for (int j = 1; j <= n * m; ++j)
          for (int k = 1; k <= n * m; ++k) {
            now[i][j] += ans[i][k] * b[k][j] % mod;
            now[i][j] %= mod;
          }
      for (int i = 1; i <= n * m; ++i)
        for (int j = 1; j <= n * m; ++j) ans[i][j] = now[i][j];
    }
    x /= 2;
    memset(now, 0, sizeof(now));
    for (int i = 1; i <= n * m; ++i)
      for (int j = 1; j <= n * m; ++j)
        for (int k = 1; k <= n * m; ++k) {
          now[i][j] += b[i][k] * b[k][j] % mod;
          now[i][j] %= mod;
        }
    for (int i = 1; i <= n * m; ++i)
      for (int j = 1; j <= n * m; ++j) b[i][j] = now[i][j];
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n * m; ++i) f[1][i] = 0;
  f[1][1] = 1;
  for (int i = 1; i <= n * m; ++i) a[i][i] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      dq = (i - 1) * m + j;
      if (i > 1) a[dq][dq - m] = 1;
      if (i < n) a[dq][dq + m] = 1;
      if (j > 1) a[dq][dq - 1] = 1;
      if (j < m) a[dq][dq + 1] = 1;
    }
  dqt = 1;
  for (int i = 1; i <= n * m; ++i) bb[i] = 1;
  for (int zz = 1; zz <= q; ++zz) {
    scanf("%d", &z);
    if (z == 1) {
      scanf("%d%d%d", &x, &y, &t);
      mul(a, t - dqt);
      memset(now, 0, sizeof(now));
      for (int i = 1; i <= 1; ++i)
        for (int j = 1; j <= n * m; ++j)
          for (int k = 1; k <= n * m; ++k) {
            now[i][j] += f[i][k] * ans[k][j] % mod;
            now[i][j] %= mod;
          }
      for (int i = 1; i <= n * m; ++i) f[1][i] = now[1][i];
      printf("%I64d\n", f[1][(x - 1) * m + y]);
      dqt = t;
    } else if (z == 2) {
      scanf("%d%d%d", &x, &y, &t);
      mul(a, t - dqt);
      memset(now, 0, sizeof(now));
      for (int i = 1; i <= 1; ++i)
        for (int j = 1; j <= n * m; ++j)
          for (int k = 1; k <= n * m; ++k) {
            now[i][j] += f[i][k] * ans[k][j] % mod;
            now[i][j] %= mod;
          }
      for (int i = 1; i <= n * m; ++i) f[1][i] = now[1][i];
      f[1][(x - 1) * m + y] = 0;
      dq = (x - 1) * m + y;
      bb[dq] = 0;
      a[dq][dq] = 0;
      if (x > 1) a[dq][dq - m] = 0, a[dq - m][dq] = 0;
      if (x < n) a[dq][dq + m] = 0, a[dq + m][dq] = 0;
      if (y > 1) a[dq][dq - 1] = 0, a[dq - 1][dq] = 0;
      if (y < m) a[dq][dq + 1] = 0, a[dq + 1][dq] = 0;
      dqt = t;
    } else if (z == 3) {
      scanf("%d%d%d", &x, &y, &t);
      mul(a, t - dqt);
      memset(now, 0, sizeof(now));
      for (int i = 1; i <= 1; ++i)
        for (int j = 1; j <= n * m; ++j)
          for (int k = 1; k <= n * m; ++k) {
            now[i][j] += f[i][k] * ans[k][j] % mod;
            now[i][j] %= mod;
          }
      for (int i = 1; i <= n * m; ++i) f[1][i] = now[1][i];
      dq = (x - 1) * m + y;
      a[dq][dq] = 1;
      bb[dq] = 1;
      if (x > 1)
        a[dq][dq - m] = min(bb[dq], bb[dq - m]), a[dq - m][dq] = a[dq][dq - m];
      if (x < n)
        a[dq][dq + m] = min(bb[dq], bb[dq + m]), a[dq + m][dq] = a[dq][dq + m];
      if (y > 1)
        a[dq][dq - 1] = min(bb[dq], bb[dq - 1]), a[dq - 1][dq] = a[dq][dq - 1];
      if (y < m)
        a[dq][dq + 1] = min(bb[dq], bb[dq + 1]), a[dq + 1][dq] = a[dq][dq + 1];
      dqt = t;
    }
  }
  return 0;
}
