#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 100;   int bitRow[maxn][maxn], bitCol[maxn][maxn], n, m;   bool a[maxn][maxn];   void addRow(int fi, int idx, int val) {     while (idx <= 1000) {       bitRow[fi][idx] += val;       idx += idx & (-idx);     }   }   void addCol(int fi, int idx, int val) {     while (idx <= 1000) {       bitCol[fi][idx] += val;       idx += idx & (-idx);     }   }   int getRow(int fi, int se) {     if (se == 0) return 0;     int ret = 0;     while (se > 0) {       ret += bitRow[fi][se];       se -= se & (-se);     }     return ret;   }   int getCol(int fi, int se) {     if (se == 0) return 0;     int ret = 0;     while (se > 0) {       ret += bitCol[fi][se];       se -= se & (-se);     }     return ret;   }   int getRight(int fi, int se) {     int lo = se, hi = m;     while (lo != hi) {       int mid = (lo + hi + 1) / 2;       if (getRow(fi, mid) - getRow(fi, se - 1) == mid - se + 1)         lo = mid;       else         hi = mid - 1;     }     return lo;   }   int getLeft(int fi, int se) {     int lo = 1, hi = se;     while (lo != hi) {       int mid = (lo + hi) / 2;       if (getRow(fi, se) - getRow(fi, mid - 1) == se - mid + 1)         hi = mid;       else         lo = mid + 1;     }     return lo;   }   int getDown(int fi, int se) {     int lo = fi, hi = n;     while (lo != hi) {       int mid = (lo + hi + 1) / 2;       if (getCol(se, mid) - getCol(se, fi - 1) == mid - fi + 1)         lo = mid;       else         hi = mid - 1;     }     return lo;   }   int getUp(int fi, int se) {     int lo = 1, hi = fi;     while (lo != hi) {       int mid = (lo + hi) / 2;       if (getCol(se, fi) - getCol(se, mid - 1) == fi - mid + 1)         hi = mid;       else         lo = mid + 1;     }     return lo;   }   int main() {     ios_base::sync_with_stdio(false);     int q;     cin >> n >> m >> q;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         bool cur;         cin >> cur;         a[i][j] = cur;         addRow(i, j, cur);         addCol(j, i, cur);       }     while (q--) {       int op, fi, se;       cin >> op >> fi >> se;       if (op == 1) {         a[fi][se] = !a[fi][se];         if (a[fi][se] == 0) {           addRow(fi, se, -1);           addCol(se, fi, -1);         } else {           addRow(fi, se, +1);           addCol(se, fi, +1);         }       } else {         int cur = 0, left = 0, right = 10000;         for (int i = fi; i >= 1; i--) {           if (a[i][se] == 0) break;           right = min(right, getRight(i, se));           left = max(left, getLeft(i, se));           cur = max(cur, (fi - i + 1) * (right - left + 1));         }         left = 0, right = 10000;         for (int i = fi; i <= n; i++) {           if (a[i][se] == 0) break;           right = min(right, getRight(i, se));           left = max(left, getLeft(i, se));           cur = max(cur, (i - fi + 1) * (right - left + 1));         }         int up = 0, down = 10000;         for (int i = se; i >= 1; i--) {           if (a[fi][i] == 0) break;           up = max(up, getUp(fi, i));           down = min(down, getDown(fi, i));           cur = max(cur, (se - i + 1) * (down - up + 1));         }         up = 0, down = 10000;         for (int i = se; i <= m; i++) {           if (a[fi][i] == 0) break;           up = max(up, getUp(fi, i));           down = min(down, getDown(fi, i));           cur = max(cur, (i - se + 1) * (down - up + 1));         }         cout << cur << endl;       }     }   }