#include <bits/stdc++.h>
using namespace std;
template <class T>
struct OpMin {
  static inline T init() { return numeric_limits<T>::max(); }
  static inline T get(T const& a, T const& b) { return a < b ? a : b; }
};
template <class T>
struct OpMax {
  static inline T init() { return numeric_limits<T>::lowest(); }
  static inline T get(T const& a, T const& b) { return a > b ? a : b; }
};
template <class T>
struct OpSum {
  static inline T init() { return 0; }
  static inline T get(T const& a, T const& b) { return a + b; }
};
template <int n, class T, class Op>
class IntervalTree {
  T t[n * 2];

 public:
  IntervalTree(T init = Op::init());
  void set(int i, T val = Op::init());
  T get(int l, int r);
};
template <int n, class T, class Op>
IntervalTree<n, T, Op>::IntervalTree(T init) {
  for (int i = 0; i < n; i++) t[i + n] = init;
  for (int i = n - 1; i; i--) t[i] = Op::get(t[i + i], t[i + i + 1]);
}
template <int n, class T, class Op>
void IntervalTree<n, T, Op>::set(int i, T val) {
  for (i += n, t[i] = val, i >>= 1; i; i >>= 1)
    t[i] = Op::get(t[i + i], t[i + i + 1]);
}
template <int n, class T, class Op>
T IntervalTree<n, T, Op>::get(int l, int r) {
  l += n, r += n;
  if (l == r) return t[l];
  T resl = t[l];
  T resr = t[r];
  while (l < r - 1) {
    if (!(l & 1)) resl = Op::get(resl, t[l + 1]);
    if (r & 1) resr = Op::get(t[r - 1], resr);
    l >>= 1, r >>= 1;
  }
  return Op::get(resl, resr);
}
IntervalTree<1024, int, OpMin<int> > tminx[1024];
IntervalTree<1024, int, OpMax<int> > tmaxx[1024];
IntervalTree<1024, int, OpMin<int> > tminy[1024];
IntervalTree<1024, int, OpMax<int> > tmaxy[1024];
int n, m;
int board[1024][1024];
void update(int i, int j) {
  tminx[i].set(j, board[i][j] ? m : j);
  tmaxx[i].set(j, board[i][j] ? -1 : j);
  tminy[j].set(i, board[i][j] ? n : i);
  tmaxy[j].set(i, board[i][j] ? -1 : i);
}
void init() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) update(i, j);
}
void flip(int i, int j) {
  board[i][j] = !board[i][j];
  update(i, j);
}
int get(int i, int j) {
  int best = 0;
  int ml = n, mr = n;
  for (int t = j; t >= 0; t--) {
    ml = min(ml, i - tmaxy[t].get(0, i));
    mr = min(mr, tminy[t].get(i, n - 1) - i);
    best = max(best, (ml + mr - 1) * (j - t + 1));
  }
  ml = n, mr = n;
  for (int t = j; t < m; t++) {
    ml = min(ml, i - tmaxy[t].get(0, i));
    mr = min(mr, tminy[t].get(i, n - 1) - i);
    best = max(best, (ml + mr - 1) * (t - j + 1));
  }
  ml = m, mr = m;
  for (int t = i; t >= 0; t--) {
    ml = min(ml, j - tmaxx[t].get(0, j));
    mr = min(mr, tminx[t].get(j, m - 1) - j);
    best = max(best, (ml + mr - 1) * (i - t + 1));
  }
  ml = m, mr = m;
  for (int t = i; t < n; t++) {
    ml = min(ml, j - tmaxx[t].get(0, j));
    mr = min(mr, tminx[t].get(j, m - 1) - j);
    best = max(best, (ml + mr - 1) * (t - i + 1));
  }
  return best;
}
int main() {
  int q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &board[i][j]);
  init();
  for (int i = 0; i < q; i++) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1)
      flip(x - 1, y - 1);
    else
      printf("%d\n", get(x - 1, y - 1));
  }
  return 0;
}
