#include <bits/stdc++.h>
using namespace std;
const int N = 1010, INF = 1 << 30;
int a[N][N], x, y;
int n, m, q, L[N][N], R[N][N], U[N][N], D[N][N];
void update() {
  a[x][y] ^= 1;
  for (int j = 1; j <= m; j++) L[x][j] = a[x][j] ? L[x][j - 1] + 1 : 0;
  for (int j = m; j; j--) R[x][j] = a[x][j] ? R[x][j + 1] + 1 : 0;
  for (int i = 1; i <= n; i++) U[i][y] = a[i][y] ? U[i - 1][y] + 1 : 0;
  for (int i = n; i; i--) D[i][y] = a[i][y] ? D[i + 1][y] + 1 : 0;
}
void query() {
  if (!a[x][y])
    printf("0\n");
  else {
    int up = INF, down = INF, ans = 0;
    for (int j = y; j; j--) {
      up = min(U[x][j], up), down = min(D[x][j], down);
      ans = max(ans, (up + down - 1) * (y - j + 1));
    }
    up = INF, down = INF;
    for (int j = y; j <= m; j++) {
      up = min(U[x][j], up), down = min(D[x][j], down);
      ans = max(ans, (up + down - 1) * (j - y + 1));
    }
    int left = INF, right = INF;
    for (int i = x; i; i--) {
      left = min(left, L[i][y]), right = min(right, R[i][y]);
      ans = max(ans, (left + right - 1) * (x - i + 1));
    }
    left = INF, right = INF;
    for (int i = x; i <= n; i++) {
      left = min(left, L[i][y]), right = min(right, R[i][y]);
      ans = max(ans, (left + right - 1) * (i - x + 1));
    }
    printf("%d\n", ans);
  }
}
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[i] + j);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) L[i][j] = a[i][j] ? L[i][j - 1] + 1 : 0;
    for (int j = m; j; j--) R[i][j] = a[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] = a[i][j] ? U[i - 1][j] + 1 : 0;
    for (int i = n; i; i--) D[i][j] = a[i][j] ? D[i + 1][j] + 1 : 0;
  }
  for (int i = 1; i <= q; i++) {
    int op;
    scanf("%d %d %d", &op, &x, &y);
    if (op == 1)
      update();
    else
      query();
  }
  return 0;
}
