#include <bits/stdc++.h>
using namespace std;
int getint() {
  unsigned int c;
  int x = 0;
  while (((c = getchar()) - '0') >= 10) {
    if (c == '-') return -getint();
    if (!~c) exit(0);
  }
  do {
    x = (x << 3) + (x << 1) + (c - '0');
  } while (((c = getchar()) - '0') < 10);
  return x;
}
pair<int, int> rotate(int x, int y, int h, int w, int k) {
  pair<int, int> res;
  if (k == 0) res.first = x, res.second = y;
  if (k == 1) res.first = y, res.second = h - x - 1;
  if (k == 2) res.first = h - x - 1, res.second = w - y - 1;
  if (k == 3) res.first = w - y - 1, res.second = x;
  return res;
}
template <class T>
T max_area(T *h, int n, int m) {
  int i, t;
  T res = 0;
  if (n < 1) return 0;
  vector<int> sideL(n, 0), sideR(n, n), stk(n);
  for (i = t = 0; i < n; i++) {
    while (t > 0 and h[i] <= h[stk[t - 1]]) t--;
    if (t) sideL[i] = stk[t - 1] + 1;
    stk[t++] = i;
  }
  for (i = n - 1, t = 0; ~i; --i) {
    while (t > 0 and h[i] <= h[stk[t - 1]]) t--;
    if (t) sideR[i] = stk[t - 1];
    stk[t++] = i;
  }
  for (i = 0; i < n; i++) {
    if (sideR[i] <= m) continue;
    if (sideL[i] > m) continue;
    res = max(res, h[i] * (sideR[i] - sideL[i]));
  }
  return res;
}
int N, M, Q;
int grid[4][1111][1111];
int height[4], width[4];
int in[1111][1111];
int hist[4][1111][1111];
int as[1111];
int main() {
  int i, j, k, tcc, tc = 1 << 28;
  for (tcc = 0; tcc < tc; tcc++) {
    N = getint();
    M = getint();
    Q = getint();
    height[0] = height[2] = N;
    width[0] = width[2] = M;
    height[1] = height[3] = M;
    width[1] = width[3] = N;
    for (i = 0; i < N; i++)
      for (j = 0; j < M; j++) in[i][j] = getint();
    for (k = 0; k < 4; k++) {
      for (i = 0; i < N; i++)
        for (j = 0; j < M; j++) {
          int x = rotate(i, j, N, M, k).first;
          int y = rotate(i, j, N, M, k).second;
          grid[k][x][y] = in[i][j];
        }
    }
    int x, y, xx, yy;
    for (k = 0; k < 4; k++) {
      for (y = 0; y < width[k]; y++) {
        hist[k][y][0] = 0;
        if (grid[k][0][y]) hist[k][y][0]++;
        for (x = 1; x < height[k]; x++) {
          if (grid[k][x][y]) {
            hist[k][y][x] = hist[k][y][x - 1] + 1;
          } else {
            hist[k][y][x] = 0;
          }
        }
      }
    }
    while (Q--) {
      int op = getint(), X = getint() - 1, Y = getint() - 1;
      if (op == 1) {
        for (k = 0; k < 4; k++) {
          x = rotate(X, Y, N, M, k).first;
          y = rotate(X, Y, N, M, k).second;
          if (grid[k][x][y]) {
            grid[k][x][y] = 0;
            int d = hist[k][y][x];
            for (; x < height[k]; x++) {
              if (hist[k][y][x] == 0) break;
              hist[k][y][x] -= d;
            }
          } else {
            grid[k][x][y] = 1;
            int d = 1;
            if (x > 0) d += hist[k][y][x - 1];
            for (; x < height[k]; x++) {
              if (grid[k][x][y] == 0) break;
              hist[k][y][x] += d;
            }
          }
        }
      } else {
        int res = 0;
        for (k = 0; k < 4; k++) {
          x = rotate(X, Y, N, M, k).first;
          y = rotate(X, Y, N, M, k).second;
          for (j = 0; j < width[k]; j++) as[j] = hist[k][j][x];
          res = max(res, max_area(as, width[k], y));
        }
        cout << res << endl;
      }
    }
  }
  return 0;
}
