#include <bits/stdc++.h>
using namespace std;
static int a[1002][1002];
static int dp[1002][1002][4];
static const int di[4] = {0, 0, -1, 1};
static const int dj[4] = {-1, 1, 0, 0};
int main(int argc, const char* argv[]) {
  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];
  n += 2;
  m += 2;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      dp[i][j][0] = a[i][j] ? dp[i][j - 1][0] : j;
      dp[i][j][2] = a[i][j] ? dp[i - 1][j][2] : i;
    }
  for (int i = n - 1; i >= 0; i--)
    for (int j = m - 1; j >= 0; j--) {
      dp[i][j][1] = a[i][j] ? dp[i][j + 1][1] : j;
      dp[i][j][3] = a[i][j] ? dp[i + 1][j][3] : i;
    }
  while (q-- > 0) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      if (a[x][y]) {
        for (int d = 0; d < 4; d++) {
          int i = x, j = y;
          int s = (d <= 1 ? y : x);
          while (a[i][j]) {
            dp[i][j][d] = s;
            i -= di[d];
            j -= dj[d];
          }
        }
        a[x][y] = 0;
      } else {
        a[x][y] = 1;
        for (int d = 0; d < 4; d++) {
          int i = x, j = y;
          int s = dp[i + di[d]][j + dj[d]][d];
          while (a[i][j]) {
            dp[i][j][d] = s;
            i -= di[d];
            j -= dj[d];
          }
        }
      }
    } else {
      int best = 0;
      for (int d = 0; d <= 1; d++) {
        int bu = dp[x][y][2];
        int bd = dp[x][y][3];
        int j = y;
        while (a[x][j]) {
          bu = max(bu, dp[x][j][2]);
          bd = min(bd, dp[x][j][3]);
          best = max(best, (bd - bu - 1) * (abs(j - y) + 1));
          j += dj[d];
        }
      }
      for (int d = 2; d <= 3; d++) {
        int br = dp[x][y][1];
        int bl = dp[x][y][0];
        int i = x;
        while (a[i][y]) {
          br = min(br, dp[i][y][1]);
          bl = max(bl, dp[i][y][0]);
          best = max(best, (br - bl - 1) * (abs(i - x) + 1));
          i += di[d];
        }
      }
      cout << best << endl;
    }
  }
  return 0;
}
