#include <bits/stdc++.h>
using namespace std;
long long n, m, k, q, t = 1;
long long mul(long long a, long long b) {
  return (a * b) % ((long long)1e9 + 7);
}
vector<vector<long long> > mult(const vector<vector<long long> >& a,
                                const vector<vector<long long> >& b) {
  vector<vector<long long> > v(a.size(), vector<long long>(b[0].size()));
  for (long long i = 0; i < a.size(); i++)
    for (long long j = 0; j < b[0].size(); j++)
      for (long long k = 0; k < a[0].size(); k++)
        v[i][j] = ((mul(a[i][k], b[k][j]) + v[i][j])) % ((long long)1e9 + 7);
  return v;
}
vector<vector<long long> > pow(const vector<vector<long long> >& v,
                               long long p) {
  if (p == 0) {
    vector<vector<long long> > pp(v.size(), vector<long long>(v.size()));
    for (long long i = 0; i < pp.size(); i++) pp[i][i] = 1;
    return pp;
  }
  if (p == 1) return v;
  if (p % 2 == 1)
    return mult(pow(v, p - 1), v);
  else
    return pow(mult(v, v), p / 2);
}
long long f(long long i, long long j) { return m * (i - 1) + j - 1; }
void fill(const vector<vector<long long> >& c, vector<vector<long long> >& a) {
  a.assign(a.size(), vector<long long>(a[0].size(), 0));
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) {
      if (c[i][j] == 0) continue;
      k = f(i, j);
      a[k][k] = 1;
      if (i > 1) {
        a[k][k - m] = 1;
      }
      if (i < n) {
        a[k][k + m] = 1;
      }
      if (j > 1) {
        a[k][k - 1] = 1;
      }
      if (j < m) {
        a[k][k + 1] = 1;
      }
    }
}
void print(vector<vector<long long> >& v) {
  cout << endl << endl << endl;
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v[0].size(); j++) cout << v[i][j] << " ";
    cout << endl;
  }
  cout << endl << endl << endl;
}
int main() {
  cin >> n >> m >> q;
  vector<vector<long long> > v(n * m, vector<long long>(1, 0));
  v[0][0] = 1;
  vector<vector<long long> > a(n * m, vector<long long>(n * m, 0));
  vector<vector<long long> > c(n + 1, vector<long long>(m + 1, 1));
  fill(c, a);
  int time = 1;
  vector<vector<long long> > b;
  while (q--) {
    long long t, x, y, pt;
    cin >> t >> x >> y >> pt;
    if (t == 1) {
      b = pow(a, pt - time);
      time = pt;
      v = mult(b, v);
      cout << v[f(x, y)][0] << endl;
    }
    if (t == 2) {
      b = pow(a, pt - time);
      time = pt;
      v = mult(b, v);
      c[x][y] = 0;
      fill(c, a);
      v[f(x, y)][0] = 0;
    }
    if (t == 3) {
      b = pow(a, pt - time);
      time = pt;
      v = mult(b, v);
      c[x][y] = 1;
      fill(c, a);
      v[f(x, y)][0] = 0;
    }
  }
  return 0;
}
