#include <bits/stdc++.h>
using namespace std;
const int N = 20;
const int MOD = (int)1e9 + 7;
const int dx[] = {0, -1, 0, 1, 0};
const int dy[] = {0, 0, 1, 0, -1};
struct Matrix {
  long long mat[N][N];
};
bool blocked[N][N];
int m, n, q;
int size;
Matrix operator*(const Matrix a, const Matrix b) {
  Matrix c;
  for (int i = 0; i < size; ++i)
    for (int j = 0; j < size; ++j) {
      c.mat[i][j] = 0;
      for (int k = 0; k < size; ++k)
        c.mat[i][j] = (c.mat[i][j] + a.mat[i][k] * b.mat[k][j]) % MOD;
    }
  return c;
}
Matrix power(Matrix a, int p) {
  Matrix ans;
  memset(ans.mat, 0, sizeof(ans.mat));
  for (int i = 0; i < size; ++i) ans.mat[i][i] = 1;
  for (; p; p >>= 1) {
    if (p & 1) ans = ans * a;
    a = a * a;
  }
  return ans;
}
int getIndex(int x, int y) { return x * n + y; }
void update(Matrix &a) {
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j) {
      int cur = getIndex(i, j);
      for (int k = 0; k < size; ++k) a.mat[cur][k] = 0;
      if (blocked[i][j]) continue;
      for (int d = 0; d < 5; ++d) {
        int x = i + dx[d], y = j + dy[d];
        if (x < 0 || y < 0 || x >= m || y >= n || blocked[x][y]) continue;
        a.mat[cur][getIndex(x, y)] = 1;
      }
    }
}
void multiply(Matrix gap, long long ans[]) {
  int newAns[N];
  for (int i = 0; i < size; ++i) {
    newAns[i] = 0;
    for (int j = 0; j < size; ++j)
      newAns[i] = (newAns[i] + ans[j] * gap.mat[i][j]) % MOD;
  }
  for (int i = 0; i < size; ++i) ans[i] = newAns[i];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> m >> n >> q;
  size = m * n;
  Matrix a;
  update(a);
  long long ans[N];
  memset(ans, 0, sizeof(ans));
  ans[0] = 1;
  int lastT = 1;
  while (q--) {
    int type, x, y, t;
    cin >> type >> x >> y >> t;
    --x;
    --y;
    Matrix gap = power(a, t - lastT - 1);
    multiply(gap, ans);
    multiply(a, ans);
    if (type != 1) {
      blocked[x][y] ^= 1;
      update(a);
    }
    if (type == 1) cout << ans[getIndex(x, y)] << '\n';
    lastT = t;
  }
  return 0;
}
