#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5, INF = 1e9 + 5;
int n, m, q, qt, x, y, ltor[N][N], rtol[N][N], utod[N][N], dtou[N][N], ans;
bool matrix[N][N];
int solve(vector<int> &v, int indx) {
  indx--;
  vector<int> lft, rght;
  for (int i = 0; i <= indx; i++) lft.push_back(v[i]);
  reverse(lft.begin(), lft.end());
  for (int i = indx; i < v.size(); i++) rght.push_back(v[i]);
  int ans = lft.front(), curmin = lft.front(), l = 0, r = 0;
  while (l + 1 != lft.size() || r + 1 != rght.size()) {
    if (l + 1 != lft.size()) {
      if (r + 1 == rght.size()) {
        while (l + 1 != lft.size()) {
          l++;
          curmin = min(curmin, lft[l]);
          ans = max(ans, (r + l + 1) * curmin);
        }
      } else {
        while (l + 1 != lft.size() && lft[l + 1] >= rght[r + 1]) {
          l++;
          curmin = min(curmin, lft[l]);
          ans = max(ans, (r + l + 1) * curmin);
        }
      }
    }
    if (r + 1 != rght.size()) {
      if (l + 1 == lft.size()) {
        while (r + 1 != rght.size()) {
          r++;
          curmin = min(curmin, rght[r]);
          ans = max(ans, (r + l + 1) * curmin);
        }
      } else {
        while (r + 1 != rght.size() && rght[r + 1] >= lft[l + 1]) {
          r++;
          curmin = min(curmin, rght[r]);
          ans = max(ans, (r + l + 1) * curmin);
        }
      }
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> matrix[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= 1; j--) {
      if (matrix[i][j])
        ltor[i][j] = ltor[i][j + 1] + 1;
      else
        ltor[i][j] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (matrix[i][j])
        rtol[i][j] = rtol[i][j - 1] + 1;
      else
        rtol[i][j] = 0;
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = n; i >= 1; i--) {
      if (matrix[i][j])
        utod[i][j] = utod[i + 1][j] + 1;
      else
        utod[i][j] = 0;
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      if (matrix[i][j])
        dtou[i][j] = dtou[i - 1][j] + 1;
      else
        dtou[i][j] = 0;
    }
  }
  while (q--) {
    cin >> qt >> x >> y;
    if (qt == 1) {
      matrix[x][y] ^= 1;
      for (int i = m; i >= 1; i--) {
        if (matrix[x][i])
          ltor[x][i] = ltor[x][i + 1] + 1;
        else
          ltor[x][i] = 0;
      }
      for (int i = 1; i <= m; i++) {
        if (matrix[x][i])
          rtol[x][i] = rtol[x][i - 1] + 1;
        else
          rtol[x][i] = 0;
      }
      for (int i = n; i >= 1; i--) {
        if (matrix[i][y])
          utod[i][y] = utod[i + 1][y] + 1;
        else
          utod[i][y] = 0;
      }
      for (int i = 1; i <= n; i++) {
        if (matrix[i][y])
          dtou[i][y] = dtou[i - 1][y] + 1;
        else
          dtou[i][y] = 0;
      }
    } else {
      ans = 0;
      vector<int> v;
      for (int i = 1; i <= n; i++) v.push_back(ltor[i][y]);
      ans = max(ans, solve(v, x));
      v.clear();
      for (int i = 1; i <= n; i++) v.push_back(rtol[i][y]);
      ans = max(ans, solve(v, x));
      v.clear();
      for (int i = 1; i <= m; i++) v.push_back(utod[x][i]);
      ans = max(ans, solve(v, y));
      v.clear();
      for (int i = 1; i <= m; i++) v.push_back(dtou[x][i]);
      ans = max(ans, solve(v, y));
      cout << ans << "\n";
    }
  }
}
