#include <bits/stdc++.h>
using namespace std;
inline const int getint() {
  int r = 0, k = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') k = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) r = r * 10 + c - '0';
  return k * r;
}
const int N = 1005;
struct dat {
  int mp[N][N], sum[N][N], mxr[N], mxl[N], s[N], n, m;
  int getans(int *h, int pos) {
    int ret = 0;
    memset(mxr, 0, sizeof(int) * (m + 1));
    memset(mxl, 0, sizeof(int) * (m + 1));
    int top = 0;
    for (int i = (1); i <= (m); ++i) {
      while (top && h[s[top]] >= h[i]) {
        mxl[i] += mxl[s[top]];
        --top;
      }
      s[++top] = i;
      ++mxl[i];
    }
    top = 0;
    for (int i = (m); i >= (1); --i) {
      while (top && h[s[top]] >= h[i]) {
        mxr[i] += mxr[s[top]];
        --top;
      }
      s[++top] = i;
      ++mxr[i];
    }
    for (int i = (1); i <= (m); ++i)
      if ((i <= pos && i + mxr[i] - 1 >= pos) ||
          (i >= pos && i - mxl[i] + 1 <= pos))
        ret = max(ret, (mxl[i] + mxr[i] - 1) * h[i]);
    return ret;
  }
  void fix(int x, int y) {
    mp[x][y] = !mp[x][y];
    for (int i = (x); i <= (n); ++i)
      if (mp[i][y])
        sum[i][y] = sum[i - 1][y] + 1;
      else
        sum[i][y] = 0;
  }
  void init() {
    for (int j = (1); j <= (m); ++j)
      for (int i = (1); i <= (n); ++i)
        if (mp[i][j])
          sum[i][j] = sum[i - 1][j] + 1;
        else
          sum[i][j] = 0;
  }
  int ask(int x, int y) { return getans(sum[x], y); }
} a[4];
int q, n, m;
int X(int x, int y, int c) {
  if (c == 0) return x;
  if (c == 1) return n - x + 1;
  if (c == 2) return y;
  return m - y + 1;
}
int Y(int x, int y, int c) {
  if (c == 0) return y;
  if (c == 1) return y;
  if (c == 2) return x;
  return x;
}
int main() {
  n = getint();
  m = getint();
  q = getint();
  a[0].n = n;
  a[0].m = m;
  a[1].n = n;
  a[1].m = m;
  a[2].n = m;
  a[2].m = n;
  a[3].n = m;
  a[3].m = n;
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j) {
      int t = getint();
      for (int k = 0; k < (4); ++k) a[k].mp[X(i, j, k)][Y(i, j, k)] = t;
    }
  for (int i = 0; i < (4); ++i) a[i].init();
  for (int i = (1); i <= (q); ++i) {
    int c = getint(), x = getint(), y = getint();
    if (c == 1)
      for (int k = 0; k < (4); ++k) a[k].fix(X(x, y, k), Y(x, y, k));
    else {
      int ans = 0;
      if (a[0].mp[x][y] == 0) {
        puts("0");
        continue;
      }
      for (int k = 0; k < (4); ++k)
        ans = max(ans, a[k].ask(X(x, y, k), Y(x, y, k)));
      printf("%d\n", ans);
    }
  }
  return 0;
}
