#include <bits/stdc++.h>
using namespace std;
int N, M, Q;
int a[1005][1005], lft[1005][1005], rght[1005][1005], up[1005][1005],
    down[1005][1005];
int type, x, y;
int main() {
  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++)
    for (int j = 0; j < M; j++) {
      lft[i][j] = a[i][j] ? (j > 0 ? 1 + lft[i][j - 1] : 1) : 0;
      up[i][j] = a[i][j] ? (i > 0 ? 1 + up[i - 1][j] : 1) : 0;
    }
  for (int i = N - 1; i >= 0; i--)
    for (int j = M - 1; j >= 0; j--) {
      rght[i][j] = a[i][j] ? (j < M - 1 ? 1 + rght[i][j + 1] : 1) : 0;
      down[i][j] = a[i][j] ? (i < N - 1 ? 1 + down[i + 1][j] : 1) : 0;
    }
  while (Q--) {
    scanf("%d%d%d", &type, &x, &y);
    x--, y--;
    if (type == 1) {
      a[x][y] = 1 - a[x][y];
      for (int i = y; i < M; i++)
        lft[x][i] = a[x][i] ? (i > 0 ? lft[x][i - 1] + 1 : 1) : 0;
      for (int i = x; i < N; i++)
        up[i][y] = a[i][y] ? (i > 0 ? up[i - 1][y] + 1 : 1) : 0;
      for (int i = y; i >= 0; i--)
        rght[x][i] = a[x][i] ? (i < M - 1 ? rght[x][i + 1] + 1 : 1) : 0;
      for (int i = x; i >= 0; i--)
        down[i][y] = a[i][y] ? (i < N - 1 ? down[i + 1][y] + 1 : 1) : 0;
    } else {
      int ans = 0, i, u, d, l, r;
      if (a[x][y]) {
        for (i = y, u = up[x][y], d = down[x][y]; i < M && a[x][i]; i++) {
          u = min(u, up[x][i]);
          d = min(d, down[x][i]);
          ans = max(ans, (u + d - 1) * (i - y + 1));
        }
        for (i = y, u = up[x][y], d = down[x][y]; i >= 0 && a[x][i]; i--) {
          u = min(u, up[x][i]);
          d = min(d, down[x][i]);
          ans = max(ans, (u + d - 1) * (y - i + 1));
        }
        for (i = x, l = lft[x][y], r = rght[x][y]; i < N && a[i][y]; i++) {
          l = min(l, lft[i][y]);
          r = min(r, rght[i][y]);
          ans = max(ans, (r + l - 1) * (i - x + 1));
        }
        for (i = x, l = lft[x][y], r = rght[x][y]; i >= 0 && a[i][y]; i--) {
          l = min(l, lft[i][y]);
          r = min(r, rght[i][y]);
          ans = max(ans, (r + l - 1) * (x - i + 1));
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
