#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void checkMin(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
inline void checkMax(T &a, T b) {
  if (a < b) a = b;
}
const int MAX_N = 1024;
int n, m, q;
struct Bit2D {
  int n = 1000, bit[MAX_N][MAX_N];
  void add(int x, int y, int d) {
    for (int yy = y; x <= n; x += x & -x) {
      for (y = yy; y <= n; y += y & -y) {
        bit[x][y] += d;
      }
    }
  }
  int prefix(int x, int y) {
    int s = 0;
    for (int yy = y; x > 0; x -= x & -x) {
      for (y = yy; y > 0; y -= y & -y) {
        s += bit[x][y];
      }
    }
    return s;
  }
  int query(int x1, int x2, int y1, int y2) {
    return prefix(x2, y2) - prefix(x1 - 1, y2) - prefix(x2, y1 - 1) +
           prefix(x1 - 1, y1 - 1);
  }
  bool check(int x1, int x2, int y1, int y2) {
    return (x2 - x1 + 1) * (y2 - y1 + 1) == query(x1, x2, y1, y2);
  }
} t;
int calc_up(int x, int y) {
  int ans = 0, l = y, r = y, flag = false;
  for (int o = n; o >= x; --o) {
    if (flag || t.check(x, o, l, r)) {
      flag = true;
      while (1 < l && t.check(x, o, l - 1, r)) --l;
      while (r < m && t.check(x, o, l, r + 1)) ++r;
      checkMax(ans, (o - x + 1) * (r - l + 1));
    }
  }
  return ans;
}
int calc_dn(int x, int y) {
  int ans = 0, l = y, r = y, flag = false;
  for (int o = 1; o <= x; ++o) {
    if (flag || t.check(o, x, l, r)) {
      flag = true;
      while (1 < l && t.check(o, x, l - 1, r)) --l;
      while (r < m && t.check(o, x, l, r + 1)) ++r;
      checkMax(ans, (x - o + 1) * (r - l + 1));
    }
  }
  return ans;
}
int calc_lt(int x, int y) {
  int ans = 0, l = x, r = x, flag = false;
  for (int o = m; o >= y; --o) {
    if (flag || t.check(l, r, y, o)) {
      flag = true;
      while (1 < l && t.check(l - 1, r, y, o)) --l;
      while (r < n && t.check(l, r + 1, y, o)) ++r;
      checkMax(ans, (o - y + 1) * (r - l + 1));
    }
  }
  return ans;
}
int calc_rt(int x, int y) {
  int ans = 0, l = x, r = x, flag = false;
  for (int o = 1; o <= y; ++o) {
    if (flag || t.check(l, r, o, y)) {
      flag = true;
      while (1 < l && t.check(l - 1, r, o, y)) --l;
      while (r < n && t.check(l, r + 1, o, y)) ++r;
      checkMax(ans, (y - o + 1) * (r - l + 1));
    }
  }
  return ans;
}
int work(int x, int y) {
  int ans = 0;
  checkMax(ans, calc_up(x, y));
  checkMax(ans, calc_dn(x, y));
  checkMax(ans, calc_lt(x, y));
  checkMax(ans, calc_rt(x, y));
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      int a;
      scanf("%d", &a);
      if (a) {
        t.add(i, j, 1);
      }
    }
  }
  int op, x, y;
  for (int i = 0; i < int(q); ++i) {
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      t.add(x, y, t.query(x, x, y, y) == 0 ? 1 : -1);
    } else {
      printf("%d\n", t.check(x, x, y, y) ? work(x, y) : 0);
    }
  }
  return 0;
}
