#include <bits/stdc++.h>
using namespace std;
int n, m;
struct BIT {
  int lowbit(int x) { return x & (-x); }
  int x[1001];
  BIT() { memset(x, 0, sizeof(x)); }
  void update(int pos, int val) {
    while (pos <= 1000) {
      x[pos] += val;
      pos += lowbit(pos);
    }
  }
  int query(int pos) {
    int ret = 0;
    while (pos) {
      ret += x[pos];
      pos -= lowbit(pos);
    }
    return ret;
  }
} row[1001], col[1001];
int mat[1001][1001];
bool horzHaveAll(int r, int c1, int c2) {
  return (row[r].query(c2) - row[r].query(c1 - 1)) == (c2 - c1 + 1);
}
bool vertHaveAll(int c, int r1, int r2) {
  return (col[c].query(r2) - col[c].query(r1 - 1)) == (r2 - r1 + 1);
}
int maxUp(int x, int y) {
  if (mat[x][y] == 0) return 0;
  int L = 1, R = x + 1, M;
  while (R - L > 1) {
    M = (L + R) / 2;
    if (vertHaveAll(y, x - M + 1, x))
      L = M;
    else
      R = M;
  }
  return L;
}
int maxDown(int x, int y) {
  if (mat[x][y] == 0) return 0;
  int L = 1, R = n - x + 2, M;
  while (R - L > 1) {
    M = (L + R) / 2;
    if (vertHaveAll(y, x, x + M - 1))
      L = M;
    else
      R = M;
  }
  return L;
}
int maxLeft(int x, int y) {
  if (mat[x][y] == 0) return 0;
  int L = 1, R = y + 1, M;
  while (R - L > 1) {
    M = (L + R) / 2;
    if (horzHaveAll(x, y - M + 1, y))
      L = M;
    else
      R = M;
  }
  return L;
}
int maxRight(int x, int y) {
  if (mat[x][y] == 0) return 0;
  int L = 1, R = m - y + 2, M;
  while (R - L > 1) {
    M = (L + R) / 2;
    if (horzHaveAll(x, y, y + M - 1))
      L = M;
    else
      R = M;
  }
  return L;
}
int calc(vector<int> A, vector<int> B) {
  int nA = A.size(), nB = B.size();
  int ret = A[0];
  for (int i = 1; i < nA; i++) A[i] = min(A[i], A[i - 1]);
  for (int i = 1; i < nB; i++) B[i] = min(B[i], B[i - 1]);
  int p1 = 0, p2 = 0;
  while (p1 + 1 < nA || p2 + 1 < nB) {
    int choice = 1;
    if (p1 + 1 >= nA)
      choice = 2;
    else if (p2 + 1 >= nB)
      choice = 1;
    else if (A[p1 + 1] > B[p2 + 1])
      choice = 1;
    else
      choice = 2;
    if (choice == 1)
      p1++;
    else
      p2++;
    ret = max(ret, (p1 + p2 + 1) * min(A[p1], B[p2]));
  }
  return ret;
}
int MAIN() {
  int q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> mat[i][j];
      row[i].update(j, mat[i][j]);
      col[j].update(i, mat[i][j]);
    }
  for (int i = 1; i <= q; i++) {
    int op, x, y;
    cin >> op >> x >> y;
    if (op == 1) {
      int diff = (1 - mat[x][y]) - mat[x][y];
      mat[x][y] = 1 - mat[x][y];
      row[x].update(y, diff);
      col[y].update(x, diff);
    } else {
      int ans = 0;
      vector<int> v1, v2;
      v1.clear(), v2.clear();
      for (int i = y; i >= 1; i--) v1.push_back(maxUp(x, i));
      for (int i = y; i <= m; i++) v2.push_back(maxUp(x, i));
      ans = max(ans, calc(v1, v2));
      v1.clear(), v2.clear();
      for (int i = y; i >= 1; i--) v1.push_back(maxDown(x, i));
      for (int i = y; i <= m; i++) v2.push_back(maxDown(x, i));
      ans = max(ans, calc(v1, v2));
      v1.clear(), v2.clear();
      for (int i = x; i >= 1; i--) v1.push_back(maxLeft(i, y));
      for (int i = x; i <= n; i++) v2.push_back(maxLeft(i, y));
      ans = max(ans, calc(v1, v2));
      v1.clear(), v2.clear();
      for (int i = x; i >= 1; i--) v1.push_back(maxRight(i, y));
      for (int i = x; i <= n; i++) v2.push_back(maxRight(i, y));
      ans = max(ans, calc(v1, v2));
      cout << ans << endl;
    }
  }
  return 0;
}
int main() {
  ios ::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  return MAIN();
}
