#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int MOD = 1000000007;
class Matrix {
 public:
  int a[1024][1024];
  int sum[1024][1024];
  int n, m;
  void init(int n, int m) {
    this->n = n;
    this->m = m;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        sum[i][j] = sum[i][j - 1] + a[i][j];
      }
    }
  }
  void update(int x, int y) {
    a[x][y] ^= 1;
    for (int j = 1; j <= m; j++) {
      sum[x][j] = sum[x][j - 1] + a[x][j];
    }
  }
  int findR(int v[], int l, int r) {
    int p = l - 1, R = r;
    while (l < r) {
      int mid = (l + r) >> 1;
      if (mid < R && v[mid] - v[p] == mid - p)
        l = mid + 1;
      else
        r = mid;
    }
    return r - 1;
  }
  int findL(int v[], int l, int r) {
    int p = r, pos = r;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (v[p] - v[mid - 1] == p - mid + 1) {
        r = mid - 1;
        pos = mid;
      } else
        l = mid + 1;
    }
    return pos;
  }
  int query(int x, int y) {
    if (a[x][y] == 0) return 0;
    int cnt = 0;
    int area = 0;
    int l = 1, r = m;
    for (int i = x; i <= n; i++) {
      if (a[i][y] == 0) break;
      l = findL(sum[i], l, y), r = findR(sum[i], y, r + 1);
      int line = r - l + 1;
      cnt++;
      area = max(area, cnt * line);
    }
    l = 1, r = m, cnt = 0;
    for (int i = x; i >= 1; i--) {
      if (a[i][y] == 0) break;
      l = findL(sum[i], l, y), r = findR(sum[i], y, r + 1);
      int line = r - l + 1;
      cnt++;
      area = max(area, cnt * line);
    }
    return area;
  }
} X, Y;
int a;
int n, m, q;
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a);
      X.a[i][j] = a;
      Y.a[j][n - i + 1] = a;
    }
  }
  X.init(n, m);
  Y.init(m, n);
  while (q--) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      X.update(x, y);
      Y.update(y, n - x + 1);
    } else {
      printf("%d\n", max(X.query(x, y), Y.query(y, n - x + 1)));
    }
  }
  return 0;
}
