#include <bits/stdc++.h>
using namespace std;
inline int absol(int x) { return (x < 0 ? -x : x); }
int **belowZero, **aboveZero, **rightZero, **leftZero;
int A[1010][1010];
int n, m;
void flipPixel(int x, int y) {
  int i, j;
  if (A[x][y] == 1) {
    for (i = x; i <= n && A[i][y]; i++) aboveZero[i][y] = x;
    for (i = x; i > 0 && A[i][y]; i--) belowZero[i][y] = x;
    for (j = y; j <= m && A[x][j]; j++) leftZero[x][j] = y;
    for (j = y; j > 0 && A[x][j]; j--) rightZero[x][j] = y;
    A[x][y] = 0;
  } else {
    A[x][y] = 1;
    for (i = x; i <= n && A[i][y]; i++) aboveZero[i][y] = aboveZero[x - 1][y];
    for (i = x; i > 0 && A[i][y]; i--) belowZero[i][y] = belowZero[x + 1][y];
    for (j = y; j <= m && A[x][j]; j++) leftZero[x][j] = leftZero[x][y - 1];
    for (j = y; j > 0 && A[x][j]; j--) rightZero[x][j] = rightZero[x][y + 1];
  }
}
int rectLen[1010];
int calcCol(int x, int y, int tp) {
  int maxRect = 0;
  int i, j, k, tmp, cur, curH;
  int **ary = (tp ? aboveZero : belowZero);
  curH = ary[x][y];
  int minH = absol(curH - x);
  tmp = minH;
  rectLen[minH] = 1;
  maxRect = minH;
  for (j = y + 1; j <= m && A[x][j]; j++) {
    curH = ary[x][j];
    cur = absol(curH - x);
    for (k = minH - 1; k >= cur; k--) rectLen[k] = rectLen[minH];
    minH = min(minH, cur);
    rectLen[minH]++;
  }
  for (k = minH - 1; k >= 1; k--) rectLen[k] = rectLen[minH];
  minH = tmp;
  for (j = y - 1; j > 0 && A[x][j]; j--) {
    curH = ary[x][j];
    cur = absol(curH - x);
    for (k = minH - 1; k >= cur; k--) rectLen[k] += y - j - 1;
    minH = min(minH, cur);
    rectLen[minH]++;
  }
  for (k = minH - 1; k >= 1; k--) rectLen[k] += y - j - 1;
  for (k = tmp; k >= 1; k--) maxRect = max(maxRect, k * (rectLen[k]));
  return maxRect;
}
int calcRow(int x, int y, int tp) {
  int maxRect = 0;
  int i, j, k, tmp, cur, curH;
  int **ary = (tp ? rightZero : leftZero);
  curH = ary[x][y];
  int minH = absol(curH - y);
  tmp = minH;
  rectLen[minH] = 1;
  maxRect = minH;
  for (j = x + 1; j <= n && A[j][y]; j++) {
    curH = ary[j][y];
    cur = absol(curH - y);
    for (k = minH - 1; k >= cur; k--) rectLen[k] = rectLen[minH];
    minH = min(minH, cur);
    rectLen[minH]++;
  }
  for (k = minH - 1; k >= 1; k--) rectLen[k] = rectLen[minH];
  minH = tmp;
  for (j = x - 1; j > 0 && A[j][y]; j--) {
    curH = ary[j][y];
    cur = absol(curH - y);
    for (k = minH - 1; k >= cur; k--) rectLen[k] += x - j - 1;
    minH = min(minH, cur);
    rectLen[minH]++;
  }
  for (k = minH - 1; k >= 1; k--) rectLen[k] += x - j - 1;
  for (k = tmp; k >= 1; k--) maxRect = max(maxRect, k * (rectLen[k]));
  return maxRect;
}
int query(int x, int y) {
  if (!A[x][y]) return 0;
  int maxRect = 0;
  int cur;
  cur = calcCol(x, y, 0);
  maxRect = max(maxRect, cur);
  cur = calcCol(x, y, 1);
  maxRect = max(maxRect, cur);
  cur = calcRow(x, y, 0);
  maxRect = max(maxRect, cur);
  cur = calcRow(x, y, 1);
  maxRect = max(maxRect, cur);
  return maxRect;
}
int main() {
  int q;
  int i, j;
  belowZero = new int *[1010];
  aboveZero = new int *[1010];
  leftZero = new int *[1010];
  rightZero = new int *[1010];
  for (i = 0; i < 1010; i++) {
    belowZero[i] = new int[1010];
    aboveZero[i] = new int[1010];
    leftZero[i] = new int[1010];
    rightZero[i] = new int[1010];
  }
  while (cin >> n >> m >> q) {
    for (i = 0; i <= n + 1; i++) {
      leftZero[i][0] = 0;
      rightZero[i][m + 1] = m + 1;
    }
    for (j = 0; j <= m + 1; j++) {
      aboveZero[0][j] = 0;
      belowZero[n + 1][j] = n + 1;
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        cin >> A[i][j];
        if (!A[i][j]) {
          leftZero[i][j] = j;
          aboveZero[i][j] = i;
        } else {
          leftZero[i][j] = leftZero[i][j - 1];
          aboveZero[i][j] = aboveZero[i - 1][j];
        }
      }
    }
    for (i = n; i >= 1; i--) {
      for (j = m; j >= 1; j--) {
        if (!A[i][j]) {
          belowZero[i][j] = i;
          rightZero[i][j] = j;
        } else {
          belowZero[i][j] = belowZero[i + 1][j];
          rightZero[i][j] = rightZero[i][j + 1];
        }
      }
    }
    int x, y, op;
    while (q--) {
      cin >> op >> x >> y;
      if (op == 1)
        flipPixel(x, y);
      else
        cout << query(x, y) << endl;
    }
  }
}
