#include <bits/stdc++.h>
#pragma comment(linker, "/stack:102400000,102400000")
using namespace std;
int f_abs(int x) { return x < 0 ? -x : x; }
int lowbit(int x) { return (x & -x); }
int f_max(int a, int b) { return a > b ? a : b; }
int f_min(int a, int b) { return a < b ? a : b; }
int gcd(int a, int b) {
  while (int t = a % b) a = b, b = t;
  return b;
}
bool isdig(char ch) { return ch >= '0' && ch <= '9'; }
bool isup(char ch) { return ch >= 'A' && ch <= 'Z'; }
bool islow(char ch) { return ch >= 'a' && ch <= 'z'; }
void swap(int& a, int& b) {
  int t = a;
  a = b;
  b = t;
}
const double eps = 1e-9;
const int mod = 1000000007;
const int inf = 0x7fffffff;
const int N = 1003;
int n, m, q;
int mp[N][N], lt[N][N], rt[N][N], up[N][N], dn[N][N];
void init() {
  memset(mp, 0, sizeof(mp));
  memset(lt, -1, sizeof(lt));
  memset(rt, -1, sizeof(rt));
  memset(up, -1, sizeof(up));
  memset(dn, -1, sizeof(dn));
}
void get_data() {
  int i, j;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) scanf("%d", &mp[i][j]);
  }
}
void Build() {
  int i, j;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      if (mp[i][j] == 0) continue;
      up[i][j] = up[i - 1][j] + 1;
      lt[i][j] = lt[i][j - 1] + 1;
    }
  }
  for (i = n; i >= 1; --i) {
    for (j = m; j >= 1; --j) {
      if (mp[i][j] == 0) continue;
      dn[i][j] = dn[i + 1][j] + 1;
      rt[i][j] = rt[i][j + 1] + 1;
    }
  }
}
void Update(int x, int y) {
  int i, j, k;
  mp[x][y] ^= 1;
  for (i = 1, k = -1; i <= n; ++i) {
    if (mp[i][y] == 1) {
      if (k == -1) k = i;
    } else
      k = -1;
    if (~k)
      up[i][y] = i - k;
    else
      up[i][y] = -1;
  }
  for (i = n, k = -1; i >= 1; --i) {
    if (mp[i][y] == 1) {
      if (k == -1) k = i;
    } else
      k = -1;
    if (~k)
      dn[i][y] = k - i;
    else
      dn[i][y] = -1;
  }
  for (j = 1, k = -1; j <= m; ++j) {
    if (mp[x][j] == 1) {
      if (k == -1) k = j;
    } else
      k = -1;
    if (~k)
      lt[x][j] = j - k;
    else
      lt[x][j] = -1;
  }
  for (j = m, k = -1; j >= 1; --j) {
    if (mp[x][j] == 1) {
      if (k == -1) k = j;
    } else
      k = -1;
    if (~k)
      rt[x][j] = k - j;
    else
      rt[x][j] = -1;
  }
}
int calcUp(int x, int y) {
  int i, l, r, res = 0;
  l = lt[x][y], r = rt[x][y];
  for (i = x; i >= 1; --i) {
    l = f_min(l, lt[i][y]);
    r = f_min(r, rt[i][y]);
    if (~l && ~r) res = f_max(res, (r + l + 1) * (x - i + 1));
  }
  return res;
}
int calcDown(int x, int y) {
  int i, l, r, res = 0;
  l = lt[x][y], r = rt[x][y];
  for (i = x; i <= n; ++i) {
    l = f_min(l, lt[i][y]);
    r = f_min(r, rt[i][y]);
    if (~l && ~r) res = f_max(res, (r + l + 1) * (i - x + 1));
  }
  return res;
}
int calcLeft(int x, int y) {
  int j, u, d, res = 0;
  u = up[x][y], d = dn[x][y];
  for (j = y; j >= 1; --j) {
    u = f_min(u, up[x][j]);
    d = f_min(d, dn[x][j]);
    if (~u && ~d) res = f_max(res, (u + d + 1) * (y - j + 1));
  }
  return res;
}
int calcRight(int x, int y) {
  int j, u, d, res = 0;
  u = up[x][y], d = dn[x][y];
  for (j = y; j <= m; ++j) {
    u = f_min(u, up[x][j]);
    d = f_min(d, dn[x][j]);
    if (~u && ~d) res = f_max(res, (u + d + 1) * (j - y + 1));
  }
  return res;
}
void solve() {
  int op, x, y, ans;
  Build();
  while (q--) {
    scanf("%d %d %d", &op, &x, &y);
    if (op == 1)
      Update(x, y);
    else {
      ans = 0;
      if (mp[x][y]) {
        ans = f_max(ans, calcUp(x, y));
        ans = f_max(ans, calcDown(x, y));
        ans = f_max(ans, calcLeft(x, y));
        ans = f_max(ans, calcRight(x, y));
      }
      printf("%d\n", ans);
    }
  }
}
int main() {
  while (~scanf("%d %d %d", &n, &m, &q)) {
    init();
    get_data();
    solve();
  }
  return 0;
}
