#include <bits/stdc++.h>
using namespace std;
set<int> s[1005], c[1005];
int a[1005][1005];
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= m + 1; j++) {
      s[i].insert(j);
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= n + 1; j++) {
      c[i].insert(j);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      if (a[i][j] == 1) s[i].erase(j), c[j].erase(i);
    }
  }
  while (q--) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      a[x][y] ^= 1;
      if (a[x][y] == 0) s[x].insert(y), c[y].insert(x);
      if (a[x][y] == 1) s[x].erase(y), c[y].erase(x);
    } else {
      if (a[x][y] == 0) {
        cout << 0 << endl;
        continue;
      }
      int l = -2e9, r = 2e9, ans = 0;
      for (int i = x; i <= n; i++) {
        if (a[i][y] == 0) break;
        auto it = s[i].lower_bound(y);
        int nr = *it, nl = *(--it);
        l = max(l, nl);
        r = min(r, nr);
        ans = max(ans, (r - l - 1) * (i - x + 1));
      }
      l = -2e9, r = 2e9;
      for (int i = x; i >= 1; i--) {
        if (a[i][y] == 0) break;
        auto it = s[i].lower_bound(y);
        int nr = *it, nl = *(--it);
        l = max(l, nl);
        r = min(r, nr);
        ans = max(ans, (r - l - 1) * (x - i + 1));
      }
      l = -2e9, r = 2e9;
      for (int i = y; i <= m; i++) {
        if (a[x][i] == 0) break;
        auto it = c[i].lower_bound(x);
        int nr = *it, nl = *(--it);
        l = max(l, nl);
        r = min(r, nr);
        ans = max(ans, (r - l - 1) * (i - y + 1));
      }
      l = -2e9, r = 2e9;
      for (int i = y; i >= 1; i--) {
        if (a[x][i] == 0) break;
        auto it = c[i].lower_bound(x);
        int nr = *it, nl = *(--it);
        l = max(l, nl);
        r = min(r, nr);
        ans = max(ans, (r - l - 1) * (y - i + 1));
      }
      cout << ans << endl;
    }
  }
}
