#include <bits/stdc++.h>
using namespace std;
long long int mat[45][45] = {0}, id_mat[45][45] = {0};
int total;
void copym(long long int s[45][45], long long int des[45][45]) {
  for (int i = 0; i < 45; i++)
    for (int j = 0; j < 45; j++) des[i][j] = s[i][j];
}
void add(long long int &a, long long int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
void mul(long long int d[45][45], long long int mat1[45][45],
         long long int mat2[45][45]) {
  for (int i = 0; i < total; i++)
    for (int j = 0; j < total; j++) d[i][j] = 0;
  for (int i = 0; i < total; i++)
    for (int j = 0; j < total; j++)
      for (int k = 0; k < total; k++)
        d[i][j] = (d[i][j] + (mat1[i][k] * mat2[k][j])) % 1000000007;
}
void cal(long long int ret[45][45], long long int t) {
  if (t == 0) {
    copym(id_mat, ret);
    return;
  }
  if (t == 1) {
    copym(mat, ret);
    return;
  }
  cal(ret, t / 2);
  long long int tem[45][45] = {0};
  mul(tem, ret, ret);
  if (t % 2 == 1)
    mul(ret, tem, mat);
  else
    copym(tem, ret);
}
pair<int, int> get(int i, int m) {
  pair<int, int> ret;
  ret.first = i / m;
  ret.second = i % m;
  return ret;
}
int main() {
  for (int i = 0; i < 45; i++) id_mat[i][i] = 1;
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  int prevt = 0;
  total = n * m;
  long long int ret[45][45] = {0};
  copym(id_mat, ret);
  int cat[45][45] = {0};
  while (q--) {
    for (int i = 0; i < 45; i++)
      for (int j = 0; j < 45; j++) mat[i][j] = 0;
    int type, x, y, t;
    scanf("%d%d%d%d", &type, &x, &y, &t);
    x--;
    y--;
    for (int i = 0; i < total; i++)
      for (int j = 0; j < total; j++) {
        pair<int, int> f = get(i, m), s = get(j, m);
        if (abs(f.first - s.first) + abs(f.second - s.second) <= 1 &&
            !cat[f.first][f.second] && !cat[s.first][s.second])
          mat[i][j] = 1;
      }
    long long int tem[45][45] = {0};
    if (type == 1) {
      cal(tem, t - prevt - 1);
      prevt = t - 1;
      long long int tem1[45][45];
      copym(ret, tem1);
      mul(ret, tem1, tem);
      printf("%lld\n", ret[0][x * m + y]);
    } else {
      cal(tem, t - prevt - 1);
      prevt = t - 1;
      long long int tem1[45][45];
      copym(ret, tem1);
      mul(ret, tem1, tem);
      cat[x][y] = (cat[x][y] + 1) % 2;
    }
  }
  return 0;
}
