#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MOD = 1e9 + 7;
int cur = 1;
int w, n, m;
int mp[21][21];
struct Matrix {
  ll v[21][21];
  Matrix() { memset(v, 0, sizeof v); }
  void print() {
    for (int i = 1; i <= w; i++)
      for (int j = 1; j <= w; j++) printf("%I64d%c", v[i][j], " \n"[j == w]);
  }
  Matrix &operator*=(const Matrix &c) {
    Matrix a = *this, b = c;
    memset(v, 0, sizeof v);
    for (int i = 1; i <= w; i++)
      for (int j = 1; j <= w; j++)
        for (int k = 1; k <= w; k++)
          v[i][j] = (a.v[i][k] * b.v[k][j] + v[i][j]) % MOD;
    return *this;
  }
};
void update(Matrix &a) {
  int t;
  a = Matrix();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!mp[i][j]) {
        t = (i - 1) * m + j;
        if (i != 1 && !mp[i - 1][j]) a.v[(i - 2) * m + j][t] = 1;
        if (i != n && !mp[i + 1][j]) a.v[i * m + j][t] = 1;
        if (j != 1 && !mp[i][j - 1]) a.v[t - 1][t] = 1;
        if (j != m && !mp[i][j + 1]) a.v[t + 1][t] = 1;
        a.v[t][t] = 1;
      }
}
void pow_mod(Matrix &a, int p) {
  Matrix r;
  for (int i = 1; i <= w; i++) r.v[i][i] = 1;
  while (p) {
    if (p & 1) r *= a;
    a *= a;
    p >>= 1;
  }
  a = r;
}
int main() {
  int q, tp, x, y, tm;
  Matrix t, mi;
  mi.v[1][1] = 1;
  scanf("%d%d%d", &n, &m, &q);
  w = n * m;
  while (q--) {
    update(t);
    scanf("%d%d%d%d", &tp, &x, &y, &tm);
    pow_mod(t, tm - cur);
    mi *= t;
    if (tp == 1)
      printf("%I64d\n", mi.v[1][(x - 1) * m + y]);
    else if (tp == 2)
      mp[x][y] = true;
    else
      mp[x][y] = false;
    cur = tm;
  }
  return 0;
}
