#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int l[4][N][N], b[N];
int a[N][N], n, q;
int dx[] = {-1, +1, 0, 0};
int dy[] = {0, 0, -1, +1};
void update(int x, int y) {
  a[x][y] = 1 - a[x][y];
  for (int i = x; i > 0; --i)
    l[0][i][y] = a[i][y] ? l[0][i + 1][y] + a[i][y] : 0;
  for (int i = x; i <= n; ++i)
    l[1][i][y] = a[i][y] ? l[1][i - 1][y] + a[i][y] : 0;
  for (int i = y; i > 0; --i)
    l[2][x][i] = a[x][i] ? l[2][x][i + 1] + a[x][i] : 0;
  for (int i = y; i <= n; ++i)
    l[3][x][i] = a[x][i] ? l[3][x][i - 1] + a[x][i] : 0;
}
int solve(int n, int x) {
  int ans = b[x];
  int v = b[x];
  for (int i = x - 1, j = x; i > 0; --i) {
    v = min(v, b[i]);
    while (b[j + 1] >= v && j + 1 <= n) ++j;
    ans = max(ans, (j - i + 1) * v);
  }
  v = b[x];
  for (int i = x + 1, j = x; i <= n; ++i) {
    v = min(v, b[i]);
    while (b[j - 1] >= v && j - 1 > 0) --j;
    ans = max(ans, (i - j + 1) * v);
  }
  return ans;
}
int query(int x, int y) {
  if (a[x][y] == 0) return 0;
  int ans = 0;
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; ++i) b[i] = l[0][x][i];
  ans = max(ans, solve(n, y));
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; ++i) b[i] = l[1][x][i];
  ans = max(ans, solve(n, y));
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; ++i) b[i] = l[2][i][y];
  ans = max(ans, solve(n, x));
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; ++i) b[i] = l[3][i][y];
  ans = max(ans, solve(n, x));
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  int m = 0;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i)
    for (int j = 1, x; j <= m; ++j) cin >> a[i][j];
  n = max(n, m);
  for (int y = 1; y <= n; ++y)
    for (int i = n; i > 0; --i)
      l[0][i][y] = a[i][y] ? l[0][i + 1][y] + a[i][y] : 0;
  for (int y = 1; y <= n; ++y)
    for (int i = 1; i <= n; ++i)
      l[1][i][y] = a[i][y] ? l[1][i - 1][y] + a[i][y] : 0;
  for (int x = 1; x <= n; ++x)
    for (int i = n; i > 0; --i)
      l[2][x][i] = a[x][i] ? l[2][x][i + 1] + a[x][i] : 0;
  for (int x = 1; x <= n; ++x)
    for (int i = 1; i <= n; ++i)
      l[3][x][i] = a[x][i] ? l[3][x][i - 1] + a[x][i] : 0;
  for (int i = 1, t, x, y; i <= q; ++i) {
    cin >> t >> x >> y;
    if (t == 1)
      update(x, y);
    else
      cout << query(x, y) << '\n';
  }
}
