#include <bits/stdc++.h>
using namespace std;
int Up[1010][1010];
int Down[1010][1010];
int A[1010][1010];
int Left[1010][1010];
int Right[1010][1010];
int B[1010];
int seq[1010];
struct DSU {
  int Parent[1010];
  void init(int N) {
    for (int i = 1; i <= N + 1; i++) Parent[i] = i;
  }
  void merge(int x, int y) { Parent[find(x)] = y; }
  int find(int x) { return x == Parent[x] ? x : Parent[x] = find(Parent[x]); }
} L, R;
bool cmp(const int a, const int b) { return B[a] < B[b]; }
int calc(int N, int x) {
  for (int i = 1; i <= N; i++) seq[i] = i;
  sort(seq + 1, seq + N + 1, cmp);
  L.init(N), R.init(N);
  int Ans = 0;
  for (int i = N; i; i--) {
    int l = L.find(seq[i] - 1) + 1;
    int r = R.find(seq[i] + 1) - 1;
    if (l <= x && x <= r) Ans = max(Ans, (r - l + 1) * B[seq[i]]);
    L.merge(seq[i], seq[i] - 1);
    R.merge(seq[i], seq[i] + 1);
  }
  return Ans;
}
int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      if (A[i][j]) {
        Up[i][j] = Up[i - 1][j] + 1;
        Left[i][j] = Left[i][j - 1] + 1;
      }
    }
  }
  for (int i = N; i >= 1; i--) {
    for (int j = M; j >= 1; j--) {
      if (A[i][j]) {
        Down[i][j] = Down[i + 1][j] + 1;
        Right[i][j] = Right[i][j + 1] + 1;
      }
    }
  }
  while (Q--) {
    int opt, x, y;
    cin >> opt >> x >> y;
    if (opt == 1) {
      A[x][y] ^= 1;
      for (int i = x; i >= 1; i--) {
        if (A[i][y])
          Down[i][y] = Down[i + 1][y] + 1;
        else
          Down[i][y] = 0;
      }
      for (int i = y; i <= M; i++) {
        if (A[x][i])
          Left[x][i] = Left[x][i - 1] + 1;
        else
          Left[x][i] = 0;
      }
      for (int i = y; i >= 1; i--) {
        if (A[x][i])
          Right[x][i] = Right[x][i + 1] + 1;
        else
          Right[x][i] = 0;
      }
      for (int i = x; i <= N; i++) {
        if (A[i][y])
          Up[i][y] = Up[i - 1][y] + 1;
        else
          Up[i][y] = 0;
      }
    } else {
      int Ans = 0;
      for (int i = 1; i <= M; i++) B[i] = Up[x][i];
      Ans = max(Ans, calc(M, y));
      for (int i = 1; i <= M; i++) B[i] = Down[x][i];
      Ans = max(Ans, calc(M, y));
      for (int i = 1; i <= N; i++) B[i] = Left[i][y];
      Ans = max(Ans, calc(N, x));
      for (int i = 1; i <= N; i++) B[i] = Right[i][y];
      Ans = max(Ans, calc(N, x));
      cout << Ans << endl;
    }
  }
  return 0;
}
