#include <bits/stdc++.h>
using namespace std;
int n, m, q, L[1005][1005], R[1005][1005], U[1005][1005], D[1005][1005];
bool mp[1005][1005];
int gt(int mx, vector<int> &p, vector<int> &a) {
  reverse(p.begin(), p.end());
  reverse(a.begin(), a.end());
  int ans = 1 + a.end() - lower_bound(a.begin(), a.end(), mx) + p.end() -
            lower_bound(p.begin(), p.end(), mx);
  ans = ans * mx;
  int cur;
  for (int i = 0; i < (int)p.size(); i++) {
    cur = (int)p.size() - i + 1;
    cur += a.end() - lower_bound(a.begin(), a.end(), p[i]);
    if (cur * p[i] > ans) ans = cur * p[i];
  }
  for (int i = 0; i < (int)a.size(); i++) {
    cur = (int)a.size() - i + 1;
    cur += p.end() - lower_bound(p.begin(), p.end(), a[i]);
    if (cur * a[i] > ans) ans = cur * a[i];
  }
  return ans;
}
int ask(int x, int y) {
  x--;
  y--;
  if (mp[x][y] == false) return 0;
  int mx = R[x][y] - y + 1;
  vector<int> p, a;
  for (int i = x - 1; i >= 0; i--) {
    if (mp[i][y] == false) break;
    mx = min(mx, R[i][y] - y + 1);
    p.push_back(mx);
  }
  mx = R[x][y] - y + 1;
  for (int i = x + 1; i < n; i++) {
    if (mp[i][y] == false) break;
    mx = min(mx, R[i][y] - y + 1);
    a.push_back(mx);
  }
  int res = gt(R[x][y] - y + 1, p, a);
  p.clear();
  a.clear();
  mx = y - L[x][y] + 1;
  for (int i = x - 1; i >= 0; i--) {
    if (mp[i][y] == false) break;
    mx = min(mx, y - L[i][y] + 1);
    p.push_back(mx);
  }
  mx = y - L[x][y] + 1;
  for (int i = x + 1; i < n; i++) {
    if (mp[i][y] == false) break;
    mx = min(mx, y - L[i][y] + 1);
    a.push_back(mx);
  }
  res = max(res, gt(y - L[x][y] + 1, p, a));
  mx = x - U[x][y] + 1;
  p.clear();
  a.clear();
  for (int j = y - 1; j >= 0; j--) {
    if (mp[x][j] == false) break;
    mx = min(mx, x - U[x][j] + 1);
    p.push_back(mx);
  }
  mx = x - U[x][y] + 1;
  for (int j = y + 1; j < m; j++) {
    if (mp[x][j] == false) break;
    mx = min(mx, x - U[x][j] + 1);
    a.push_back(mx);
  }
  res = max(res, gt(x - U[x][y] + 1, p, a));
  mx = D[x][y] - x + 1;
  p.clear();
  a.clear();
  for (int j = y - 1; j >= 0; j--) {
    if (mp[x][j] == false) break;
    mx = min(mx, D[x][j] - x + 1);
    p.push_back(mx);
  }
  mx = D[x][y] - x + 1;
  for (int j = y + 1; j < m; j++) {
    if (mp[x][j] == false) break;
    mx = min(mx, D[x][j] - x + 1);
    a.push_back(mx);
  }
  res = max(res, gt(D[x][y] - x + 1, p, a));
  return res;
}
void up(int x, int y) {
  x--;
  y--;
  mp[x][y] = !mp[x][y];
  U[0][y] = 0;
  for (int i = 1; i < n; i++) {
    if (mp[i][y] == mp[i - 1][y])
      U[i][y] = U[i - 1][y];
    else
      U[i][y] = i;
  }
  D[n - 1][y] = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    if (mp[i][y] == mp[i + 1][y])
      D[i][y] = D[i + 1][y];
    else
      D[i][y] = i;
  }
  L[x][0] = 0;
  for (int i = 1; i < m; i++) {
    if (mp[x][i] == mp[x][i - 1])
      L[x][i] = L[x][i - 1];
    else
      L[x][i] = i;
  }
  R[x][m - 1] = m - 1;
  for (int i = m - 2; i >= 0; i--) {
    if (mp[x][i] == mp[x][i + 1])
      R[x][i] = R[x][i + 1];
    else
      R[x][i] = i;
  }
}
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> mp[i][j];
  for (int i = 0; i < n; i++) {
    L[i][0] = 0;
    for (int j = 1; j < m; j++) {
      if (mp[i][j] == mp[i][j - 1])
        L[i][j] = L[i][j - 1];
      else
        L[i][j] = j;
    }
    R[i][m - 1] = m - 1;
    for (int j = m - 2; j >= 0; j--) {
      if (mp[i][j] == mp[i][j + 1])
        R[i][j] = R[i][j + 1];
      else
        R[i][j] = j;
    }
  }
  for (int j = 0; j < m; j++) {
    U[0][j] = 0;
    for (int i = 1; i < n; i++) {
      if (mp[i][j] == mp[i - 1][j])
        U[i][j] = U[i - 1][j];
      else
        U[i][j] = i;
    }
    D[n - 1][j] = n - 1;
    for (int i = n - 2; i >= 0; i--) {
      if (mp[i][j] == mp[i + 1][j])
        D[i][j] = D[i + 1][j];
      else
        D[i][j] = i;
    }
  }
  int op, x, y;
  while (q--) {
    cin >> op >> x >> y;
    if (op == 1)
      up(x, y);
    else
      cout << ask(x, y) << endl;
  }
  return 0;
}
