#include <bits/stdc++.h>
using namespace std;
int n, m, q, d[1010][1010][4];
bool a[1001][1001];
void toggle(int x, int y) {
  a[x][y] ^= 1;
  if (a[x][y]) {
    for (int i = x; i >= 1 and a[i][y]; i--) d[i][y][2] = d[i + 1][y][2] + 1;
    for (int i = x; i <= n and a[i][y]; i++) d[i][y][0] = d[i - 1][y][0] + 1;
    for (int j = y; j >= 1 and a[x][j]; j--) d[x][j][3] = d[x][j + 1][3] + 1;
    for (int j = y; j <= m and a[x][j]; j++) d[x][j][1] = d[x][j - 1][1] + 1;
  } else {
    for (int z = 0; z < 4; z++) d[x][y][z] = 0;
    for (int i = x - 1; i >= 1 and a[i][y]; i--) d[i][y][2] = x - i;
    for (int i = x + 1; i <= n and a[i][y]; i++) d[i][y][0] = i - x;
    for (int j = y - 1; j >= 1 and a[x][j]; j--) d[x][j][3] = y - j;
    for (int j = y + 1; j <= m and a[x][j]; j++) d[x][j][1] = j - y;
  }
}
int get(int x, int y) {
  int res[4] = {0}, ret = 0;
  for (int tp = 0; tp < 4; tp++) {
    if (tp % 2)
      for (int l = x, r = x, c = d[x][y][tp]; l >= 1 and r <= n;) {
        res[tp] = max((r - l + 1) * c, res[tp]);
        if (d[l - 1][y][tp] > d[r + 1][y][tp] or r == n)
          l--, c = min(d[l][y][tp], c);
        else
          r++, c = min(d[r][y][tp], c);
      }
    else
      for (int l = y, r = y, c = d[x][y][tp]; l >= 1 and r <= m;) {
        res[tp] = max((r - l + 1) * c, res[tp]);
        if (d[x][l - 1][tp] > d[x][r + 1][tp] or r == m)
          l--, c = min(d[x][l][tp], c);
        else
          r++, c = min(d[x][r][tp], c);
      }
    ret = max(res[tp], ret);
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1, lj = 0; j <= m; j++) {
      scanf("%d", &a[i][j]);
      if (!a[i][j])
        lj = j;
      else
        d[i][j][1] = j - lj;
    }
    for (int j = m, lj = m + 1; j >= 1; j--) {
      if (!a[i][j])
        lj = j;
      else
        d[i][j][3] = lj - j;
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1, li = 0; i <= n; i++) {
      if (!a[i][j])
        li = i;
      else
        d[i][j][0] = i - li;
    }
    for (int i = n, li = n + 1; i >= 1; i--) {
      if (!a[i][j])
        li = i;
      else
        d[i][j][2] = li - i;
    }
  }
  while (q--) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1)
      toggle(x, y);
    else
      printf("%d\n", get(x, y));
  }
}
