#include <bits/stdc++.h>
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int inf = (1 << 30);
using namespace std;
int n, m, k, q;
int p[1005][1005];
int r[1005][1005], h[1005][1005], l[1005][1005], d[1005][1005];
int idl[1005], idr[1005], a[1005], b[1005], t, pp;
stack<int> st;
void printarray(int a[1005][1005]) {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%d", a[i][j]);
    cout << '\n';
  }
}
void update(int x, int y) {
  p[x][y] = 1 - p[x][y];
  for (int j = 1; j <= m; j++) {
    l[x][j] = (p[x][j] == 1 ? l[x][j - 1] + 1 : 0);
    r[x][m + 1 - j] = (p[x][m + 1 - j] == 1 ? r[x][m + 2 - j] + 1 : 0);
  }
  for (int i = 1; i <= n; i++) {
    h[i][y] = (p[i][y] == 1 ? h[i - 1][y] + 1 : 0);
    d[n + 1 - i][y] = (p[n + 1 - i][y] == 1 ? d[n + 2 - i][y] + 1 : 0);
  }
}
int solveIt(int a[], int t, int pos) {
  int res = 0;
  a[0] = a[t + 1] = -inf;
  int j = 1;
  while (!st.empty()) st.pop();
  st.push(0);
  for (int j = 1; j <= t + 1; j++) {
    if (a[st.top()] <= a[j])
      st.push(j);
    else {
      while (a[st.top()] > a[j]) {
        idr[st.top()] = j - 1;
        st.pop();
      }
      st.push(j);
    }
  }
  while (!st.empty()) st.pop();
  st.push(t + 1);
  for (int j = t; j >= 0; j--) {
    if (a[st.top()] <= a[j])
      st.push(j);
    else {
      while (a[st.top()] > a[j]) {
        idl[st.top()] = j + 1;
        st.pop();
      }
      st.push(j);
    }
  }
  for (int i = 1; i <= t; i++)
    if (idl[i] <= pos && pos <= idr[i])
      res = max(res, a[i] * (idr[i] - idl[i] + 1));
  return res;
}
int answer(int x, int y) {
  if (p[x][y] == 0) return 0;
  int S = 1, t = 0;
  for (int i = y - l[x][y] + 1; i <= y + r[x][y] - 1; i++) {
    t++;
    a[t] = h[x][i];
    b[t] = d[x][i];
  }
  S = max(S, solveIt(a, t, l[x][y]));
  S = max(S, solveIt(b, t, l[x][y]));
  t = 0;
  for (int i = x - h[x][y] + 1; i <= x + d[x][y] - 1; i++) {
    t++;
    a[t] = l[i][y];
    b[t] = r[i][y];
  }
  S = max(S, solveIt(a, t, h[x][y]));
  S = max(S, solveIt(b, t, h[x][y]));
  return S;
}
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", &p[i][j]);
      if (p[i][j] == 1) {
        l[i][j] = l[i][j - 1] + 1;
        h[i][j] = h[i - 1][j] + 1;
      }
    }
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--)
      if (p[i][j] == 1) {
        r[i][j] = r[i][j + 1] + 1;
        d[i][j] = d[i + 1][j] + 1;
      }
  for (int i = 1, op, x, y; i <= q; i++) {
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1)
      update(x, y);
    else
      printf("%d\n", answer(x, y));
  }
  return 0;
}
