#include <bits/stdc++.h>
using namespace std;
template <typename T>
T in() {
  char ch;
  T n = 0;
  bool ng = false;
  while (1) {
    ch = getchar();
    if (ch == '-') {
      ng = true;
      ch = getchar();
      break;
    }
    if (ch >= '0' && ch <= '9') break;
  }
  while (1) {
    n = n * 10 + (ch - '0');
    ch = getchar();
    if (ch < '0' || ch > '9') break;
  }
  return (ng ? -n : n);
}
template <typename T>
inline T Dist(T x1, T y1, T x2, T y2) {
  return sqrt((x1 - x2 * x1 - x2) + (y1 - y2 * y1 - y2));
}
template <typename T>
inline T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2) * POW(B, P / 2));
}
template <typename T>
inline T ABS(T a) {
  if (a < 0)
    return -a;
  else
    return a;
}
template <typename T>
inline T Gcd(T a, T b) {
  if (a < 0) return Gcd(-a, b);
  if (b < 0) return Gcd(a, -b);
  return (b == 0) ? a : Gcd(b, a % b);
}
template <typename T>
inline T Lcm(T a, T b) {
  if (a < 0) return Lcm(-a, b);
  if (b < 0) return Lcm(a, -b);
  return a * (b / Gcd(a, b));
}
long long Bigmod(long long base, long long power, long long MOD) {
  long long ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base) % MOD;
    base = (base * base) % MOD;
    power >>= 1;
  }
  return ret;
}
long long ModInverse(long long number, long long MOD) {
  return Bigmod(number, MOD - 2, MOD);
}
int Set(int N, int pos) { return N = N | (1 << pos); }
int Reset(int N, int pos) { return N = N & ~(1 << pos); }
bool Chkbit(int N, int pos) { return (bool)(N & (1 << pos)); }
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
bool isConst(char ch) {
  if (isalpha(ch) && !isVowel(ch)) return true;
  return false;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
long long int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
struct Matrix {
  long long int ar[22][22];
};
int k;
Matrix MUL(Matrix a, Matrix b) {
  Matrix ans;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      ans.ar[i][j] = 0;
      for (int kk = 0; kk < k; kk++) {
        ans.ar[i][j] = (ans.ar[i][j] + a.ar[i][kk] * b.ar[kk][j]) % 1000000007;
      }
    }
  }
  return ans;
}
Matrix Unit;
Matrix Big_Mod(Matrix a, int n) {
  Matrix ans = Unit;
  while (n) {
    if (n & 1) {
      ans = MUL(ans, a);
    }
    a = MUL(a, a);
    n /= 2;
  }
  return ans;
}
int a[22][22];
Matrix Base;
int dx[] = {1, -1, 0, 0, 0};
int dy[] = {0, 0, -1, 1, 0};
int n, m, q;
int Id[22][22];
void MakeBaseMatrix() {
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      Base.ar[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 0) continue;
      for (int kk = 0; kk < 5; kk++) {
        int first = i + dx[kk], second = j + dy[kk];
        if (first >= 0 && first < n && second >= 0 && second < m &&
            a[first][second]) {
          Base.ar[Id[i][j]][Id[first][second]] = 1;
        }
      }
    }
  }
}
void Dekhi() {
  int id = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      Id[i][j] = id++;
    }
  }
}
void Prnt(Matrix aa) {
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      cout << aa.ar[i][j] << " ";
    }
    printf("\n");
  }
  printf("\n");
}
int main() {
  n = in<int>(), m = in<int>(), q = in<int>();
  k = n * m;
  Matrix now;
  int pv = 1;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      a[i][j] = 1;
    }
  }
  Dekhi();
  memset(now.ar, 0, sizeof(now.ar));
  for (int i = 0; i < k; i++) now.ar[i][i] = 1;
  Unit = now;
  for (int i = 0; i < q; i++) {
    int tp, x, y, t;
    tp = in<int>(), x = in<int>(), y = in<int>();
    t = in<int>();
    x--, y--;
    int baki = (t - pv);
    if (tp == 1) {
      MakeBaseMatrix();
      Matrix tp = Big_Mod(Base, baki);
      now = MUL(tp, now);
      printf("%lld\n", now.ar[Id[x][y]][0]);
      pv = t;
    } else if (tp == 2) {
      MakeBaseMatrix();
      Matrix tp = Big_Mod(Base, baki);
      now = MUL(tp, now);
      a[x][y] = 0;
      pv = t;
    } else {
      MakeBaseMatrix();
      Matrix tp = Big_Mod(Base, baki);
      now = MUL(tp, now);
      a[x][y] = 1;
      pv = t;
    }
  }
  return 0;
}
