#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const int inf = 1 << 30;
int n, m, q;
int uc[MAXN][MAXN], dc[MAXN][MAXN];
int lr[MAXN][MAXN], rr[MAXN][MAXN];
int a[MAXN][MAXN];
void refresh_row(int x) {
  int last = -1;
  for (int i = 0; i < m; ++i) {
    if (a[x][i] == 0) last = i;
    lr[x][i] = last + 1;
  }
  last = m;
  for (int i = m - 1; i >= 0; --i) {
    if (a[x][i] == 0) last = i;
    rr[x][i] = last - 1;
  }
}
void refresh_col(int x) {
  int last = -1;
  for (int i = 0; i < n; ++i) {
    if (a[i][x] == 0) last = i;
    uc[x][i] = last + 1;
  }
  last = n;
  for (int i = n - 1; i >= 0; --i) {
    if (a[i][x] == 0) last = i;
    dc[x][i] = last - 1;
  }
}
int query(int x, int y) {
  int ret = 0;
  int l, r;
  l = -inf;
  r = inf;
  for (int i = x; i < n; ++i) {
    l = max(l, lr[i][y]);
    r = min(r, rr[i][y]);
    ret = max(ret, (r - l + 1) * (i - x + 1));
  }
  l = -inf;
  r = inf;
  for (int i = x; i >= 0; --i) {
    l = max(l, lr[i][y]);
    r = min(r, rr[i][y]);
    ret = max(ret, (r - l + 1) * (x - i + 1));
  }
  l = -inf;
  r = inf;
  for (int i = y; i < m; ++i) {
    l = max(l, uc[i][x]);
    r = min(r, dc[i][x]);
    ret = max(ret, (r - l + 1) * (i - y + 1));
  }
  l = -inf;
  r = inf;
  for (int i = y; i >= 0; --i) {
    l = max(l, uc[i][x]);
    r = min(r, dc[i][x]);
    ret = max(ret, (r - l + 1) * (y - i + 1));
  }
  return ret;
}
int main(void) {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", &a[i][j]);
  for (int i = 0; i < n; ++i) refresh_row(i);
  for (int j = 0; j < m; ++j) refresh_col(j);
  for (int i = 0; i < q; ++i) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    --x;
    --y;
    if (t == 1) {
      a[x][y] ^= 1;
      refresh_row(x);
      refresh_col(y);
    }
    if (t == 2) printf("%d\n", query(x, y));
  }
  return 0;
}
