#include <bits/stdc++.h>
using namespace std;
const int maxN = 1002;
int l[maxN][maxN], r[maxN][maxN], u[maxN][maxN], d[maxN][maxN], a[maxN][maxN];
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      if (a[i][j]) {
        l[i][j] = l[i][j - 1] + 1;
        u[i][j] = u[i - 1][j] + 1;
      }
    }
  for (int i = n; i; i--)
    for (int j = m; j; j--)
      if (a[i][j]) {
        r[i][j] = r[i][j + 1] + 1;
        d[i][j] = d[i + 1][j] + 1;
      }
  while (q--) {
    int t, x, y;
    scanf("%d %d %d", &t, &x, &y);
    if (t == 2) {
      int uu = x, dd = x, ans = 0, lu = -1, kr, llu, lld;
      kr = l[uu][y];
      while (kr) {
        while (uu + 1 <= n && l[uu + 1][y] >= kr) uu++;
        while (dd - 1 && l[dd - 1][y] >= kr) dd--;
        kr = min(kr, min(l[uu][y], l[dd][y]));
        ans = max(ans, (uu - dd + 1) * (kr));
        uu++;
        dd--;
        if (l[uu][y] > l[dd][y])
          dd++;
        else
          uu--;
        kr = min(kr, min(l[uu][y], l[dd][y]));
        if (!dd || uu > n) break;
      }
      uu = x;
      dd = x;
      lu = -1;
      kr = r[uu][y];
      while (kr) {
        while (uu + 1 <= n && r[uu + 1][y] >= kr) uu++;
        while (dd - 1 && kr <= r[dd - 1][y]) dd--;
        kr = min(kr, (min(r[uu][y], r[dd][y])));
        ans = max(ans, (uu - dd + 1) * (kr));
        uu++;
        dd--;
        if (r[uu][y] > r[dd][y])
          dd++;
        else
          uu--;
        kr = min(kr, (min(r[uu][y], r[dd][y])));
        if (!dd || uu > n) break;
      }
      uu = y;
      dd = y;
      lu = -1;
      kr = u[x][uu];
      while (kr) {
        while (uu + 1 <= m && u[x][uu + 1] >= kr) uu++;
        while (dd - 1 && kr <= u[x][dd - 1]) dd--;
        kr = min(kr, min(u[x][uu], u[x][dd]));
        ans = max(ans, (uu - dd + 1) * kr);
        uu++;
        dd--;
        if (u[x][uu] > u[x][dd])
          dd++;
        else
          uu--;
        kr = min(kr, min(u[x][uu], u[x][dd]));
        if (!dd || uu > m) break;
      }
      uu = y;
      dd = y;
      kr = d[x][uu];
      while (kr) {
        while (uu + 1 <= m && d[x][uu + 1] >= kr) uu++;
        while (dd - 1 && d[x][dd - 1] >= kr) dd--;
        kr = min(kr, min(d[x][uu], d[x][dd]));
        ans = max(ans, (uu - dd + 1) * (kr));
        dd--;
        uu++;
        if (d[x][uu] > d[x][dd])
          dd++;
        else
          uu--;
        kr = min(kr, min(d[x][uu], d[x][dd]));
        if (!dd || uu > m) break;
      }
      printf("%d\n", ans);
    } else {
      a[x][y] = 1 - a[x][y];
      for (int j = 1; j <= m; j++)
        if (a[x][j])
          l[x][j] = l[x][j - 1] + 1;
        else
          l[x][j] = 0;
      for (int j = m; j; j--)
        if (a[x][j])
          r[x][j] = r[x][j + 1] + 1;
        else
          r[x][j] = 0;
      for (int j = n; j; j--)
        if (a[j][y])
          d[j][y] = d[j + 1][y] + 1;
        else
          d[j][y] = 0;
      for (int j = 1; j <= n; j++)
        if (a[j][y])
          u[j][y] = u[j - 1][y] + 1;
        else
          u[j][y] = 0;
    }
  }
  cin >> n;
}
