#include <bits/stdc++.h>
using namespace std;
bool cat[20][20];
inline long long mod(long long x) { return x % 1000000007LL; }
struct mat {
  vector<vector<long long> > m;
  int r;
  int c;
  mat(int r, int c) : r(r), c(c), m(r, vector<long long>(c, 0)) {}
  const vector<long long>& operator[](int i) const { return m[i]; }
  vector<long long>& operator[](int i) { return m[i]; }
  mat operator*(const mat& a) const {
    assert(c == a.r);
    mat ans(r, a.c);
    for (int i = 0; i < r; ++i) {
      for (int j = 0; j < a.c; ++j) {
        for (int k = 0; k < c; ++k) {
          ans[i][j] += mod(m[i][k] * a[k][j]);
        }
        ans[i][j] = mod(ans[i][j]);
      }
    }
    return ans;
  }
  mat operator^(int e) const {
    assert(r == c);
    mat ans(r, c);
    for (int i = 0; i < r; ++i) {
      ans[i][i] = 1;
    }
    mat pw = *this;
    for (; e; e /= 2) {
      if (e & 1) {
        ans = ans * pw;
      }
      pw = pw * pw;
    }
    return ans;
  }
};
int rv[] = {-1, 1, 0, 0};
int cv[] = {0, 0, -1, 1};
inline int to_id(int i, int j, int m) { return i * m + j; }
inline bool valid(int i, int j, int n, int m) {
  return 0 <= i && i < n && 0 <= j && j < m;
}
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  int sz = n * m;
  mat ma(sz, sz);
  mat nw(sz, 1);
  nw[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      int q = to_id(i, j, m);
      ma[q][q] = 1;
      for (int d = 0; d < 4; ++d) {
        int ni = i + rv[d];
        int nj = j + cv[d];
        if (valid(ni, nj, n, m)) {
          ma[q][to_id(ni, nj, m)] = 1;
        }
      }
    }
  }
  int lt = 1;
  for (int i = 0; i < q; ++i) {
    int tp, x, y, t;
    scanf("%d%d%d%d", &tp, &x, &y, &t);
    --x, --y;
    nw = (ma ^ (t - lt)) * nw;
    if (tp == 1) {
      printf("%d\n", (int)nw[to_id(x, y, m)][0]);
    } else {
      cat[x][y] = tp == 2;
      int q = to_id(x, y, m);
      ma[q][q] = !cat[x][y];
      for (int d = 0; d < 4; ++d) {
        int nx = x + rv[d];
        int ny = y + cv[d];
        if (valid(nx, ny, n, m) && !cat[nx][ny]) {
          int p = to_id(nx, ny, m);
          ma[q][p] = ma[p][q] = !cat[x][y];
        }
      }
    }
    lt = t;
  }
  return 0;
}
