#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int a[maxn][maxn], n, m;
int levo[maxn][maxn];
int desno[maxn][maxn];
int gore[maxn][maxn];
int dole[maxn][maxn];
void fix(int r, int c) {
  a[r][c] = !a[r][c];
  for (int i = 1; i < m; ++i) {
    if (a[r][i - 1])
      levo[r][i] = levo[r][i - 1] + 1;
    else
      levo[r][i] = 0;
  }
  for (int i = m - 1; i >= 0; --i) {
    if (a[r][i + 1])
      desno[r][i] = desno[r][i + 1] + 1;
    else
      desno[r][i] = 0;
  }
  for (int i = 1; i < n; ++i) {
    if (a[i - 1][c])
      gore[i][c] = gore[i - 1][c] + 1;
    else
      gore[i][c] = 0;
  }
  for (int i = n - 1; i >= 0; --i) {
    if (a[i + 1][c])
      dole[i][c] = dole[i + 1][c] + 1;
    else
      dole[i][c] = 0;
  }
}
bool can(int r, int c) { return a[r][c] && r >= 0 && r < n && c >= 0 && c < m; }
int solve(int r, int c) {
  int ret = 0;
  for (int i = 0; i < 2; ++i) {
    int x1 = 0, x2 = m;
    int rn = r, cn = c, h = 1;
    while (can(rn, cn)) {
      x1 = max(x1, cn - levo[rn][cn]);
      x2 = min(x2, cn + desno[rn][cn]);
      ret = max(ret, h * (x2 - x1 + 1));
      i & 1 ? ++rn : --rn;
      ++h;
    }
  }
  for (int i = 0; i < 2; ++i) {
    int y1 = 0, y2 = n;
    int rn = r, cn = c, h = 1;
    while (can(rn, cn)) {
      y1 = max(y1, rn - gore[rn][cn]);
      y2 = min(y2, rn + dole[rn][cn]);
      ret = max(ret, h * (y2 - y1 + 1));
      i & 1 ? ++cn : --cn;
      ++h;
    }
  }
  return ret;
}
int main() {
  int q;
  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 = 1; j < m; ++j) {
      if (a[i][j - 1])
        levo[i][j] = levo[i][j - 1] + 1;
      else
        levo[i][j] = 0;
    }
    for (int j = m - 1; j >= 0; --j) {
      if (a[i][j + 1])
        desno[i][j] = desno[i][j + 1] + 1;
      else
        desno[i][j] = 0;
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 1; j < n; ++j) {
      if (a[j - 1][i])
        gore[j][i] = gore[j - 1][i] + 1;
      else
        gore[j][i] = 0;
    }
    for (int j = n - 1; j >= 0; --j) {
      if (a[j + 1][i])
        dole[j][i] = dole[j + 1][i] + 1;
      else
        dole[j][i] = 0;
    }
  }
  for (int i = 0; i < q; ++i) {
    int op, r, c;
    scanf("%d %d %d", &op, &r, &c);
    --r, --c;
    if (op == 1) {
      fix(r, c);
    } else {
      printf("%d\n", solve(r, c));
    }
  }
  return 0;
}
