#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int a[N][N];
int n, m, q;
int __left[N][N], _right[N][N], up[N][N], down[N][N];
void update_up(int i, int j) {
  if (a[i][j])
    up[i][j] = up[i - 1][j] + 1;
  else
    up[i][j] = 0;
}
void update_down(int i, int j) {
  if (a[i][j])
    down[i][j] = down[i + 1][j] + 1;
  else
    down[i][j] = 0;
}
void update_left(int i, int j) {
  if (a[i][j])
    __left[i][j] = __left[i][j - 1] + 1;
  else
    __left[i][j] = 0;
}
void update_right(int i, int j) {
  if (a[i][j])
    _right[i][j] = _right[i][j + 1] + 1;
  else
    _right[i][j] = 0;
}
void input() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      update_left(i, j);
      update_up(i, j);
    }
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--) {
      update_down(i, j);
      update_right(i, j);
    }
}
void update(int x, int y) {
  a[x][y] ^= 1;
  for (int i = x; i <= n; i++) update_up(i, y);
  for (int col = y; col <= m; col++) update_left(x, col);
  for (int row = x; row >= 1; row--) update_down(row, y);
  for (int col = m; col >= 1; col--) update_right(x, col);
}
void maximize(int &u, int v) { u = max(u, v); }
void minimize(int &u, int v) { u = min(u, v); }
int cal(int *b, int pos, int len) {
  int l = pos, r = pos;
  int top = b[pos];
  int ans = 0;
  while (true) {
    maximize(ans, (r - l + 1) * top);
    if (l == 1 && r == len) return ans;
    if (l == 1) {
      r++;
      minimize(top, b[r]);
    } else if (r == len) {
      l--;
      minimize(top, b[l]);
    } else {
      if (b[l - 1] >= b[r + 1]) {
        l--;
        minimize(top, b[l]);
      } else {
        r++;
        minimize(top, b[r]);
      }
    }
  }
}
int solve(int x, int y) {
  int b[N];
  int ans = 0;
  for (int i = 1; i <= m; i++) b[i] = up[x][i];
  maximize(ans, cal(b, y, m));
  for (int i = 1; i <= m; i++) b[i] = down[x][i];
  maximize(ans, cal(b, y, m));
  for (int i = 1; i <= n; i++) b[i] = __left[i][y];
  maximize(ans, cal(b, x, n));
  for (int i = 1; i <= n; i++) b[i] = _right[i][y];
  maximize(ans, cal(b, x, n));
  return ans;
}
int main() {
  input();
  while (q--) {
    int type, x, y;
    scanf("%d %d %d", &type, &x, &y);
    if (type == 1) {
      update(x, y);
    } else {
      printf("%d\n", solve(x, y));
    }
  }
}
