#include <bits/stdc++.h>
using namespace std;
int n, m, q, tp, x, y, t;
struct Matrix {
  int row, col;
  int values[410][410];
  Matrix(int _row = 0, int _col = 0) {
    row = _row;
    col = _col;
    for (int i = 0; i < row; ++i)
      for (int j = 0; j < col; ++j) values[i][j] = 0;
  }
  Matrix operator*(const Matrix &b) {
    Matrix c(row, b.col);
    for (int i = 0; i < row; ++i)
      for (int j = 0; j < b.col; ++j)
        for (int k = 0; k < col; ++k)
          c.values[i][j] =
              (c.values[i][j] + values[i][k] * 1ll * b.values[k][j]) %
              1000000007;
    return c;
  }
  Matrix operator^(int y) {
    --y;
    Matrix base, ans;
    memcpy(base.values, values, sizeof(values));
    memcpy(ans.values, values, sizeof(values));
    base.row = ans.row = row;
    base.col = ans.col = col;
    while (y) {
      if (y & 1) {
        ans = ans * base;
      }
      y >>= 1;
      base = base * base;
    }
    return ans;
  }
  void print() {
    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < col; ++j) printf("%d ", values[i][j]);
      printf("\n");
    }
    printf("\n");
  }
};
int main() {
  scanf("%d %d %d", &n, &m, &q);
  Matrix base(n * m, n * m);
  Matrix ans(n * m, 1);
  ans.values[0][0] = 1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      int pos = i * m + j;
      if (j + 1 < m) base.values[pos][pos + 1] = 1;
      if (j > 0) base.values[pos][pos - 1] = 1;
      if (i + 1 < n) base.values[pos][pos + m] = 1;
      if (i > 0) base.values[pos][pos - m] = 1;
      base.values[pos][pos] = 1;
    }
  int curT = 1;
  for (int i = 0; i < q; ++i) {
    scanf("%d %d %d %d", &tp, &x, &y, &t);
    --x;
    --y;
    ans = (base ^ (t - curT)) * ans;
    if (tp == 1) {
      printf("%d\n", ans.values[x * m + y][0]);
    }
    if (tp == 2) {
      int pos = x * m + y;
      if (y + 1 < m) base.values[pos][pos + 1] = 0;
      if (y > 0) base.values[pos][pos - 1] = 0;
      if (x + 1 < n) base.values[pos][pos + m] = 0;
      if (x > 0) base.values[pos][pos - m] = 0;
      base.values[pos][pos] = 0;
      ans.values[pos][0] = 0;
    }
    if (tp == 3) {
      int pos = x * m + y;
      if (y + 1 < m) base.values[pos][pos + 1] = 1;
      if (y > 0) base.values[pos][pos - 1] = 1;
      if (x + 1 < n) base.values[pos][pos + m] = 1;
      if (x > 0) base.values[pos][pos - m] = 1;
      base.values[pos][pos] = 1;
    }
    curT = t;
  }
  return 0;
}
