#include <bits/stdc++.h>
using namespace std;
int A[1111][1111];
int h[4][1111][1111];
int M, N, Q, i, j, x;
void Preprocess() {
  for (j = 1; j <= N; j++) h[0][0][j] = 0;
  for (i = 1; i <= M; i++)
    for (j = 1; j <= N; j++)
      if (A[i][j])
        h[0][i][j] = 1 + h[0][i - 1][j];
      else
        h[0][i][j] = 0;
  for (j = 1; j <= N; j++) h[1][M + 1][j] = 0;
  for (i = M; i >= 1; i--)
    for (j = 1; j <= N; j++)
      if (A[i][j])
        h[1][i][j] = 1 + h[1][i + 1][j];
      else
        h[1][i][j] = 0;
  for (i = 1; i <= M; i++) h[2][0][i] = 0;
  for (j = 1; j <= N; j++)
    for (i = 1; i <= M; i++)
      if (A[i][j])
        h[2][j][i] = 1 + h[2][j - 1][i];
      else
        h[2][j][i] = 0;
  for (i = 1; i <= M; i++) h[3][N + 1][i] = 0;
  for (j = N; j >= 1; j--)
    for (i = 1; i <= M; i++)
      if (A[i][j])
        h[3][j][i] = 1 + h[3][j + 1][i];
      else
        h[3][j][i] = 0;
}
void Update(int r, int c) {
  A[r][c] = 1 - A[r][c];
  j = c;
  for (i = 1; i <= M; i++)
    if (A[i][j])
      h[0][i][j] = 1 + h[0][i - 1][j];
    else
      h[0][i][j] = 0;
  for (i = M; i >= 1; i--)
    if (A[i][j])
      h[1][i][j] = 1 + h[1][i + 1][j];
    else
      h[1][i][j] = 0;
  i = r;
  for (j = 1; j <= N; j++)
    if (A[i][j])
      h[2][j][i] = 1 + h[2][j - 1][i];
    else
      h[2][j][i] = 0;
  for (j = N; j >= 1; j--)
    if (A[i][j])
      h[3][j][i] = 1 + h[3][j + 1][i];
    else
      h[3][j][i] = 0;
}
int stk[1111][2], nstk;
int FindLargestAreaRectangle(int dir, int x, int xneed, int xmax) {
  int amax = 0, j, jleft, height, left, right, a;
  nstk = 0;
  h[dir][x][xmax + 1] = 0;
  for (j = 1; j <= xmax + 1; j++)
    if (h[dir][x][j] == 0) {
      while (nstk >= 1) {
        height = stk[nstk][0];
        left = stk[nstk][1];
        right = j - 1;
        if (left <= xneed && xneed <= right) {
          a = height * (right - left + 1);
          if (a > amax) amax = a;
        }
        nstk--;
      }
    } else {
      jleft = j;
      while (nstk >= 1 && stk[nstk][0] >= h[dir][x][j]) {
        height = stk[nstk][0];
        left = stk[nstk][1];
        right = j - 1;
        if (left <= xneed && xneed <= right) {
          a = height * (right - left + 1);
          if (a > amax) amax = a;
        }
        if (stk[nstk][1] < jleft) jleft = stk[nstk][1];
        nstk--;
      }
      nstk++;
      stk[nstk][0] = h[dir][x][j];
      stk[nstk][1] = jleft;
    }
  return amax;
}
int Query(int r, int c) {
  if (A[r][c] == 0) return 0;
  int a1, a2, a3, a4;
  a1 = FindLargestAreaRectangle(0, r, c, N);
  a2 = FindLargestAreaRectangle(1, r, c, N);
  a3 = FindLargestAreaRectangle(2, c, r, M);
  a4 = FindLargestAreaRectangle(3, c, r, M);
  return max(max(a1, a2), max(a3, a4));
}
int main() {
  int op, x, y;
  scanf("%d %d %d", &M, &N, &Q);
  for (i = 1; i <= M; i++)
    for (j = 1; j <= N; j++) scanf("%d", &(A[i][j]));
  Preprocess();
  while (Q--) {
    scanf("%d %d %d", &op, &x, &y);
    if (op == 1)
      Update(x, y);
    else
      printf("%d\n", Query(x, y));
  }
  return 0;
}
