#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void maz(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void miz(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
void RI() {}
template <typename... T>
void RI(int &head, T &...tail) {
  scanf("%d", &head);
  RI(tail...);
}
const int N = 1010;
int n, m;
int A[N][N];
set<int> Sr[N], Sc[N];
void change(int x, int y) {
  if (A[x][y] == 0) {
    A[x][y] = 1;
    Sr[x].insert(y);
    Sc[y].insert(x);
  } else {
    A[x][y] = 0;
    Sr[x].erase(y);
    Sc[y].erase(x);
  }
}
int hei[N];
int L[N], R[N];
stack<int> S;
int calc(int n, int x) {
  while (!S.empty()) S.pop();
  for (int i = 1; i <= n; i++) {
    while (S.size() && hei[S.top()] >= hei[i]) S.pop();
    if (S.size() == 0)
      L[i] = 0;
    else
      L[i] = S.top();
    S.push(i);
  }
  while (!S.empty()) S.pop();
  for (int i = n; i >= 1; i--) {
    while (S.size() && hei[S.top()] >= hei[i]) S.pop();
    if (S.size() == 0)
      R[i] = n + 1;
    else
      R[i] = S.top();
    S.push(i);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (L[i] < x && R[i] > x) {
      maz(ans, hei[i] * (R[i] - L[i] - 1));
    }
  return ans;
  return 0;
}
int solve1(int x, int y) {
  for (int i = 1; i <= n; i++) {
    hei[i] = (*Sr[i].lower_bound(y)) - y;
  }
  return calc(n, x);
}
int solve2(int x, int y) {
  for (int i = 1; i <= n; i++) {
    if (A[i][y] == 1)
      hei[i] = 0;
    else {
      __typeof(Sr[i].begin()) it = Sr[i].lower_bound(y);
      it--;
      hei[i] = y - (*it);
    }
  }
  return calc(n, x);
}
int solve3(int x, int y) {
  for (int j = 1; j <= m; j++) {
    hei[j] = (*Sc[j].lower_bound(x)) - x;
  }
  return calc(m, y);
}
int solve4(int x, int y) {
  for (int j = 1; j <= m; j++) {
    if (A[x][j] == 1) {
      hei[j] = 0;
      continue;
    }
    __typeof(Sc[j].begin()) it = Sc[j].lower_bound(x);
    it--;
    hei[j] = x - (*it);
  }
  return calc(m, y);
}
int solve(int x, int y) {
  int ans = 0;
  if (A[x][y] == 1) return 0;
  maz(ans, solve1(x, y));
  maz(ans, solve2(x, y));
  maz(ans, solve3(x, y));
  maz(ans, solve4(x, y));
  return ans;
}
void init() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      A[i][j] ^= 1;
      if (A[i][j] == 1) {
        Sr[i].insert(j);
        Sc[j].insert(i);
      }
    }
  for (int i = 1; i <= n; i++) {
    Sr[i].insert(m + 1);
    Sr[i].insert(0);
  }
  for (int j = 1; j <= m; j++) {
    Sc[j].insert(n + 1);
    Sc[j].insert(0);
  }
}
int main() {
  int q;
  RI(n, m, q);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) RI(A[i + 1][j + 1]);
  init();
  while (q--) {
    int k, x, y;
    RI(k, x, y);
    if (k == 1) {
      change(x, y);
    } else {
      printf("%d\n", solve(x, y));
    }
  }
  return 0;
}
