#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 77;
int n, m, q;
int a[N][N], R[N][N], D[N][N], L[N][N], U[N][N];
inline void Reset(int x, int y) {
  for (int j = m; j > 0; --j) R[x][j] = (a[x][j] == 0 ? j : R[x][j + 1]);
  for (int j = 1; j <= m; ++j) L[x][j] = (a[x][j] == 0 ? j : L[x][j - 1]);
  for (int i = 1; i <= n; ++i) U[i][y] = (a[i][y] == 0 ? i : U[i - 1][y]);
  for (int i = n; i > 0; --i) D[i][y] = (a[i][y] == 0 ? i : D[i + 1][y]);
}
inline int Get(int x, int y) {
  if (a[x][y] == 0) return 0;
  int res = 1;
  int ll, rr, dd, uu;
  ll = 0;
  rr = m + 1;
  for (int i = x; i <= n; ++i)
    ll = max(ll, L[i][y]), rr = min(rr, R[i][y]),
    res = max(res, (i - x + 1) * (rr - ll - 1));
  ll = 0;
  rr = m + 1;
  for (int i = x; i > 0; --i)
    ll = max(ll, L[i][y]), rr = min(rr, R[i][y]),
    res = max(res, (x - i + 1) * (rr - ll - 1));
  uu = 0;
  dd = n + 1;
  for (int j = y; j <= m; ++j)
    uu = max(uu, U[x][j]), dd = min(dd, D[x][j]),
    res = max(res, (j - y + 1) * (dd - uu - 1));
  uu = 0;
  dd = n + 1;
  for (int j = y; j > 0; --j)
    uu = max(uu, U[x][j]), dd = min(dd, D[x][j]),
    res = max(res, (y - j + 1) * (dd - uu - 1));
  return res;
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) scanf("%d", &a[i][j]);
  for (int i = 1; i <= n; ++i) R[i][m + 1] = m + 1;
  for (int i = 1; i <= n; ++i)
    for (int j = m; j > 0; --j) R[i][j] = (a[i][j] == 0 ? j : R[i][j + 1]);
  for (int i = 1; i <= n; ++i) L[i][0] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) L[i][j] = (a[i][j] == 0 ? j : L[i][j - 1]);
  for (int j = 1; j <= m; ++j) U[0][j] = 0;
  for (int j = 1; j <= m; ++j)
    for (int i = 1; i <= n; ++i) U[i][j] = (a[i][j] == 0 ? i : U[i - 1][j]);
  for (int j = 1; j <= m; ++j) D[n + 1][j] = n + 1;
  for (int j = 1; j <= m; ++j)
    for (int i = n; i > 0; --i) D[i][j] = (a[i][j] == 0 ? i : D[i + 1][j]);
  while (q--) {
    int tp, x, y;
    scanf("%d %d %d", &tp, &x, &y);
    if (tp == 1)
      a[x][y] ^= 1, Reset(x, y);
    else
      printf("%d\n", Get(x, y));
  }
  return 0;
}
