#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100;
int g[maxn][maxn];
int n, m, u[maxn][maxn], d[maxn][maxn], l[maxn][maxn], r[maxn][maxn], h[maxn];
void change(int x, int y) {
  g[x][y] ^= 1;
  for (int i = y; i <= m; ++i) l[x][i] = g[x][i] ? l[x][i - 1] + 1 : 0;
  for (int i = y; i >= 1; --i) r[x][i] = g[x][i] ? r[x][i + 1] + 1 : 0;
  for (int i = x; i <= n; ++i) u[i][y] = g[i][y] ? u[i - 1][y] + 1 : 0;
  for (int i = x; i >= 1; --i) d[i][y] = g[i][y] ? d[i + 1][y] + 1 : 0;
}
int getmax(int L, int R, int p) {
  int ans = h[p];
  int curmin = h[p], curl = p, curr = p;
  while (1) {
    if (curl == L && curr == R) break;
    int lh = -1, rh = -1;
    if (curl - 1 >= L) lh = h[curl - 1];
    if (curr + 1 <= R) rh = h[curr + 1];
    if (lh > rh)
      curl--;
    else
      curr++;
    curmin = min(curmin, max(lh, rh));
    ans = max(ans, (curr - curl + 1) * curmin);
  }
  return ans;
}
int query(int x, int y) {
  int ans = 0;
  int ll = l[x][y], rr = r[x][y], uu = u[x][y], dd = d[x][y];
  int L = y - ll + 1, R = y + rr - 1;
  for (int i = L; i <= R; ++i) h[i] = u[x][i];
  if (L <= R) ans = max(ans, getmax(L, R, y));
  for (int i = L; i <= R; ++i) h[i] = d[x][i];
  if (L <= R) ans = max(ans, getmax(L, R, y));
  L = x - uu + 1, R = x + dd - 1;
  for (int i = L; i <= R; ++i) h[i] = l[i][y];
  if (L <= R) ans = max(ans, getmax(L, R, x));
  for (int i = L; i <= R; ++i) h[i] = r[i][y];
  if (L <= R) ans = max(ans, getmax(L, R, x));
  return ans;
}
int main() {
  int q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      scanf("%d", &g[i][j]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) l[i][j] = g[i][j] ? l[i][j - 1] + 1 : 0;
    for (int j = m; j >= 1; --j) r[i][j] = g[i][j] ? r[i][j + 1] + 1 : 0;
  }
  for (int j = 1; j <= m; ++j) {
    for (int i = 1; i <= n; ++i) u[i][j] = g[i][j] ? u[i - 1][j] + 1 : 0;
    for (int i = n; i >= 1; --i) d[i][j] = g[i][j] ? d[i + 1][j] + 1 : 0;
  }
  for (int i = 1, op, x, y; i <= q; ++i) {
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      change(x, y);
    } else {
      printf("%d\n", query(x, y));
    }
  }
  return 0;
}
