#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T &t, T f) {
  if (t > f) t = f;
}
template <class T>
void chmax(T &t, T f) {
  if (t < f) t = f;
}
int n, m, q;
int a[1010][1010];
int up[1010][1010], down[1010][1010];
int le[1010][1010], ri[1010][1010];
void init() {}
void input() {
  cin >> n >> m >> q;
  memset(a, 0, (int)sizeof(a));
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++) cin >> a[i + 1][j + 1];
  n += 2;
  m += 2;
}
void dump() {
  cout << "board" << endl;
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) cout << a[i][j];
    cout << endl;
  }
  cout << endl;
  cout << "up" << endl;
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) cout << up[i][j];
    cout << endl;
  }
  cout << endl;
  cout << "down" << endl;
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) cout << down[i][j];
    cout << endl;
  }
  cout << endl;
  cout << "left" << endl;
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) cout << le[i][j];
    cout << endl;
  }
  cout << endl;
  cout << "right" << endl;
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) cout << ri[i][j];
    cout << endl;
  }
  cout << endl;
}
void upd(int i, int j, int op) {
  up[i][j] = 0;
  down[i][j] = 0;
  le[i][j] = 0;
  ri[i][j] = 0;
  int x, y, cnt;
  if (op == 0) {
    x = i + 1, y = j, cnt = 1;
    while (x < n && a[x][y]) up[x][y] = cnt++, x++;
  }
  if (op == 1) {
    x = i - 1, y = j, cnt = 1;
    while (x >= 0 && a[x][y]) down[x][y] = cnt++, x--;
  }
  if (op == 2) {
    x = i, y = j + 1, cnt = 1;
    while (y < m && a[x][y]) le[x][y] = cnt++, y++;
  }
  if (op == 3) {
    x = i, y = j - 1, cnt = 1;
    while (y >= 0 && a[x][y]) ri[x][y] = cnt++, y--;
  }
}
void solve() {
  memset(up, 0, (int)sizeof(up));
  memset(down, 0, (int)sizeof(down));
  memset(le, 0, (int)sizeof(le));
  memset(ri, 0, (int)sizeof(ri));
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++)
      if (a[i][j] == 0) {
        upd(i, j, 0);
        upd(i, j, 1);
        upd(i, j, 2);
        upd(i, j, 3);
      }
  for (int _ = (0); _ < (q); _++) {
    int op, x, y;
    cin >> op >> x >> y;
    if (op == 1) {
      a[x][y] = !a[x][y];
      if (a[x][y] == 0) {
        upd(x, y, 0);
        upd(x, y, 1);
        upd(x, y, 2);
        upd(x, y, 3);
      } else {
        int i, j;
        i = x, j = y;
        while (a[i][y] == 1) i--;
        upd(i, y, 0);
        i = x, j = y;
        while (a[i][y] == 1) i++;
        upd(i, y, 1);
        i = x, j = y;
        while (a[x][j] == 1) j--;
        upd(x, j, 2);
        i = x, j = y;
        while (a[x][j] == 1) j++;
        upd(x, j, 3);
      }
    } else {
      int res = 0;
      int u, d, l, r;
      l = 1010, r = 1010;
      for (int i = x; i < n; i++) {
        if (a[i][y] == 0) break;
        chmin(l, le[i][y]);
        chmin(r, ri[i][y]);
        chmax(res, (abs(i - x) + 1) * (l + r - 1));
      }
      l = 1010, r = 1010;
      for (int i = x; i >= 0; i--) {
        if (a[i][y] == 0) break;
        chmin(l, le[i][y]);
        chmin(r, ri[i][y]);
        chmax(res, (abs(i - x) + 1) * (l + r - 1));
      }
      u = 1010, d = 1010;
      for (int j = y; j < m; j++) {
        if (a[x][j] == 0) break;
        chmin(u, up[x][j]);
        chmin(d, down[x][j]);
        chmax(res, (abs(j - y) + 1) * (u + d - 1));
      }
      u = 1010, d = 1010;
      for (int j = y; j >= 0; j--) {
        if (a[x][j] == 0) break;
        chmin(u, up[x][j]);
        chmin(d, down[x][j]);
        chmax(res, (abs(j - y) + 1) * (u + d - 1));
      }
      cout << res << endl;
    }
  }
}
int main() {
  init();
  input();
  solve();
  return 0;
}
