#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[1010][1010];
set<int> st[1011];
set<int> st1[1011];
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      if (!a[i][j]) st[j].insert(i);
      if (!a[i][j]) st1[i].insert(j);
    }
    st1[i].insert(0);
    st1[i].insert(m + 1);
  }
  for (int j = 1; j <= m; j++) {
    st[j].insert(0);
    st[j].insert(n + 1);
  }
  int op, x, y;
  set<int>::iterator it;
  while (k--) {
    int r = 0;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      if (!a[x][y]) {
        st[y].erase(st[y].find(x));
        st1[x].erase(st1[x].find(y));
      } else {
        st[y].insert(x);
        st1[x].insert(y);
      }
      a[x][y] = !a[x][y];
    } else {
      int r1 = 1e9;
      int l1 = -1e9;
      for (int i = y; i <= m; i++) {
        if (!a[x][i]) break;
        it = st[i].lower_bound(x);
        r1 = min(r1, *it);
        it--;
        l1 = max(l1, *it);
        r = max(r, (abs(l1 - r1) - 1) * (abs(i - y) + 1));
      }
      r1 = 1e9;
      l1 = -1e9;
      for (int i = y; i >= 1; i--) {
        if (!a[x][i]) break;
        it = st[i].lower_bound(x);
        r1 = min(r1, *it);
        it--;
        l1 = max(l1, *it);
        r = max(r, (abs(l1 - r1) - 1) * (abs(i - y) + 1));
      }
      r1 = 1e9;
      l1 = -1e9;
      for (int i = x; i <= n; i++) {
        if (!a[i][y]) break;
        it = st1[i].lower_bound(y);
        r1 = min(r1, *it);
        it--;
        l1 = max(l1, *it);
        r = max(r, (abs(l1 - r1) - 1) * (abs(i - x) + 1));
      }
      r1 = 1e9;
      l1 = -1e9;
      for (int i = x; i >= 1; i--) {
        if (!a[i][y]) break;
        it = st1[i].lower_bound(y);
        r1 = min(r1, *it);
        it--;
        l1 = max(l1, *it);
        r = max(r, (abs(l1 - r1) - 1) * (abs(i - x) + 1));
      }
      printf("%d\n", r);
    }
  }
  return 0;
}
