#include <bits/stdc++.h>
using namespace std;
int n, m, o, x, y, i, j, k, l, r, h, a[4][1005][1005], b[1005][1005];
void f() {
  for (k = 4; k--;)
    for (i = 1; i < 1005; i++)
      for (j = x ? x : 1; j < (x ? x + 1 : 1005); j++)
        y = x ? y : j,
        a[k][i][k % 2 ? j : y] = b[k - 2 ? k % 2 ? j : i : max(0, n - i + 1)]
                                  [k - 3 ? k % 2 ? i : y : max(0, m - i + 1)]
                                     ? a[k][i - 1][k % 2 ? j : y] + 1
                                     : 0;
}
int main() {
  cin >> n >> m >> o;
  for (i = n; i--;)
    for (j = m; j--;) scanf("%d", &b[n - i][m - j]);
  for (f(); cin >> o >> x >> y;) {
    if (o -= 2)
      b[x][y] ^= 1, f();
    else {
      for (k = 0; k < 4; k++) {
        i = k % 2 ? y : x;
        i = k > 1 ? (k % 2 ? m : n) - i + 1 : i;
        l = r = j = k % 2 ? x : y;
        for (h = a[k][i][j]; h; h--) {
          for (; l && a[k][i][l] >= h;) l--;
          for (; a[k][i][r] >= h;) r++;
          o = max(o, (r - l - 1) * h);
        }
      }
      cout << o << ' ';
    }
  }
}
