#include <bits/stdc++.h>
using namespace std;
static inline bool get(int &v) {
  int s = 1, c;
  while (!isdigit(c = getchar()) && c != '-') {
    if (c == EOF) break;
  }
  if (c == EOF) return 0;
  if (c == '-')
    s = 0, v = 0;
  else
    v = c ^ 48;
  for (; isdigit(c = getchar()); v = (v << 1) + (v << 3) + (c ^ 48))
    ;
  v = (s ? v : -v);
  return 1;
}
const int MAXN = 1002;
const int MAXM = 1002;
const int INF = 1000 * 1000 * 1000;
set<int> coord_false[2][MAXN];
int dx[2][2] = {{-1, 1}, {0, 0}};
int dy[2][2] = {{0, 0}, {-1, 1}};
bool state[MAXN][MAXM];
void get_border(set<int> &s, int pos, int &left, int &right) {
  set<int>::iterator I = s.lower_bound(pos);
  if (*I == pos) {
    left = right = pos;
    return;
  }
  set<int>::iterator prev = I;
  --prev;
  left = *prev;
  right = *I;
}
int main() {
  int i, j;
  int N, M, Q;
  char c;
  get(N);
  get(M);
  get(Q);
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= M; j++) {
      c = getchar();
      if (c == '1') {
        state[i][j] = true;
      } else {
        state[i][j] = false;
        coord_false[0][i].insert(j);
        coord_false[1][j].insert(i);
      }
      getchar();
    }
  }
  for (i = 1; i <= N; i++) {
    coord_false[0][i].insert(0);
    coord_false[0][i].insert(M + 1);
  }
  for (j = 1; j <= M; j++) {
    coord_false[1][j].insert(0);
    coord_false[1][j].insert(N + 1);
  }
  int op, x, y;
  int angle, dir, len;
  for (i = 0; i < Q; i++) {
    get(op);
    get(x);
    get(y);
    if (op == 1) {
      if (state[x][y]) {
        state[x][y] = false;
        coord_false[0][x].insert(y);
        coord_false[1][y].insert(x);
      } else {
        state[x][y] = true;
        coord_false[0][x].erase(coord_false[0][x].find(y));
        coord_false[1][y].erase(coord_false[1][y].find(x));
      }
    } else {
      if (!state[x][y]) {
        printf("0\n");
        continue;
      }
      int res = 0;
      for (angle = 0; angle < 2; angle++) {
        for (dir = 0; dir < 2; dir++) {
          int now_x, now_y;
          int ans = 0;
          int border_left = -INF, border_right = INF, border_h;
          len = 0;
          while (1) {
            now_x = x + len * dx[angle][dir];
            now_y = y + len * dy[angle][dir];
            if (now_x < 1 || now_x > N || now_y < 1 || now_y > M) break;
            int left, right;
            if (angle == 0)
              get_border(coord_false[0][now_x], now_y, left, right);
            else
              get_border(coord_false[1][now_y], now_x, left, right);
            border_left = max(border_left, left);
            border_right = min(border_right, right);
            border_h = border_right - border_left - 1;
            if (border_h <= 0) break;
            ans = max(ans, (len + 1) * border_h);
            len++;
          }
          res = max(res, ans);
        }
      }
      printf("%d\n", res);
    }
  }
}
