#include <bits/stdc++.h>
using namespace std;
char _;
const int maxN = 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
const int base = 701;
const int SQ = 317;
const int maxL = 302;
struct Mat {
  int n, m;
  int a[20][20];
  Mat(int x, int y, int fl = 0) {
    n = x;
    m = y;
    for (int i = 0; i < 20; i++)
      for (int j = 0; j < 20; j++)
        if (i == j)
          a[i][j] = fl;
        else
          a[i][j] = 0;
  }
};
Mat operator*(const Mat &p, const Mat &q) {
  Mat ans(p.n, q.m);
  for (int i = 0; i < p.n; i++)
    for (int j = 0; j < q.m; j++)
      for (int k = 0; k < p.m; k++)
        ans.a[i][j] = (ans.a[i][j] + (1LL) * p.a[i][k] * q.a[k][j] % mod) % mod;
  return ans;
}
Mat power(Mat p, int k) {
  Mat ans(p.n, p.m, 1);
  while (k) {
    if (k & 1) ans = ans * p;
    k >>= 1;
    p = p * p;
  }
  return ans;
}
int a[20][20];
int n, m;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool is_ok(int x, int y) {
  if (x < 0 || y < 0 || n <= x || m <= y) return false;
  return true;
}
Mat make() {
  Mat ans(n * m, n * m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 1) continue;
      ans.a[i * m + j][i * m + j] = 1;
      for (int k = 0; k < 4; k++) {
        int v = i + dx[k], u = j + dy[k];
        if (is_ok(v, u) && a[v][u] == 0) ans.a[i * m + j][v * m + u] = 1;
      }
    }
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q;
  cin >> n >> m >> q;
  Mat p(n * m, 1);
  p.a[0][0] = 1;
  Mat qq = make();
  int cur = 1;
  for (int i = 0; i < q; i++) {
    int tp, x, y, t;
    cin >> tp >> x >> y >> t;
    x--;
    y--;
    int dif = t - cur;
    p = power(qq, dif) * p;
    cur = t;
    if (tp == 1)
      cout << p.a[x * m + y][0] << endl;
    else {
      a[x][y] ^= 1;
      qq = make();
    }
  }
  return 0;
}
