#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 4e18;
const int inf = 2e9;
const int N = 1005;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int up[N][N], down[N][N], lef[N][N], rig[N][N];
int a[N][N];
void update(int x, int y) {
  int i, j;
  a[x][y] ^= 1;
  if (a[x][y]) {
    down[x][y] = down[x + 1][y] + a[x][y];
    up[x][y] = up[x - 1][y] + a[x][y];
    lef[x][y] = lef[x][y - 1] + a[x][y];
    rig[x][y] = rig[x][y + 1] + a[x][y];
  } else {
    down[x][y] = 0;
    up[x][y] = 0;
    lef[x][y] = 0;
    rig[x][y] = 0;
  }
  i = x + 1;
  while (a[i][y]) {
    up[i][y] = up[i - 1][y] + a[i][y];
    i++;
  }
  i = x - 1;
  while (a[i][y]) {
    down[i][y] = down[i + 1][y] + a[i][y];
    --i;
  }
  j = y - 1;
  while (a[x][j]) {
    rig[x][j] = rig[x][j + 1] + a[x][j];
    j--;
  }
  j = y + 1;
  while (a[x][j]) {
    lef[x][j] = lef[x][j - 1] + a[x][j];
    j++;
  }
}
int main(void) {
  int n, i, j, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) scanf("%d", &a[i][j]);
  for (j = 1; j <= m; ++j)
    for (i = 1; i <= n; ++i)
      if (a[i][j]) up[i][j] = up[i - 1][j] + a[i][j];
  for (j = 1; j <= m; ++j)
    for (i = n; i >= 1; --i)
      if (a[i][j]) down[i][j] = down[i + 1][j] + a[i][j];
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j)
      if (a[i][j]) lef[i][j] = lef[i][j - 1] + a[i][j];
  for (i = 1; i <= n; ++i)
    for (j = m; j >= 1; --j)
      if (a[i][j]) rig[i][j] = rig[i][j + 1] + a[i][j];
  while (q--) {
    int type, x, y;
    scanf("%d %d %d", &type, &x, &y);
    if (type == 2) {
      int ans = 0, l, r;
      int lim = up[x][y];
      l = y, r = y;
      while (lim) {
        while (l && up[x][l] >= lim) l--;
        while (r <= m && up[x][r] >= lim) r++;
        ans = max(ans, lim * (r - l - 1));
        lim--;
      }
      lim = down[x][y];
      l = y, r = y;
      while (lim) {
        while (l && down[x][l] >= lim) l--;
        while (r <= m && down[x][r] >= lim) r++;
        ans = max(ans, lim * (r - l - 1));
        lim--;
      }
      lim = rig[x][y];
      l = x, r = x;
      while (lim) {
        while (l && rig[l][y] >= lim) l--;
        while (r <= n && rig[r][y] >= lim) r++;
        ans = max(ans, lim * (r - l - 1));
        lim--;
      }
      lim = lef[x][y];
      l = x, r = x;
      while (lim) {
        while (l && lef[l][y] >= lim) l--;
        while (r <= n && lef[r][y] >= lim) r++;
        ans = max(ans, lim * (r - l - 1));
        lim--;
      }
      printf("%d\n", ans);
    } else
      update(x, y);
  }
  return 0;
}
