#include <bits/stdc++.h>
using namespace std;
static const int N = 1000;
int t[N][N];
int d[4][N][N];
int di[4] = {1, 0, -1, 0};
int dj[4] = {0, 1, 0, -1};
int n, m, q;
int p[N];
bool check(int k, int i) {
  if (i < 0) return 0;
  if (k) return i < m;
  return i < n;
}
int solve(int c, int b) {
  int glob = 1;
  int res = 0;
  int l = c;
  int d = c;
  while (glob) {
    while (check(b, d + 1) && p[d] == p[d + 1]) d++;
    while (check(b, l - 1) && p[l] == p[l - 1]) l--;
    if (res < (d - l + 1) * (min(p[l], p[d])))
      res = (d - l + 1) * (min(p[l], p[d]));
    if (!check(b, l - 1) && !check(b, d + 1))
      glob = 0;
    else {
      if (!check(b, l - 1))
        d++;
      else {
        if (!check(b, d + 1))
          l--;
        else {
          if (p[d + 1] > p[l - 1])
            d++;
          else
            l--;
        }
      }
    }
  }
  return res;
}
int main() {
  scanf("%i", &n);
  scanf("%i", &m);
  scanf("%i", &q);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%i", &t[i][j]);
  int si, sj, ei, ej;
  for (int k = 0; k < 4; k++) {
    si = di[k] * di[k] * ((n - 1) * (1 - di[k]) / 2);
    sj = dj[k] * dj[k] * ((m - 1) * (1 - dj[k]) / 2);
    ei = n - si - 1;
    ej = m - sj - 1;
    int i = si;
    int j = sj;
    int sum = 0;
    while ((!di[k] && i < n) || (!dj[k] && j < m)) {
      if (t[i][j])
        sum += t[i][j];
      else
        sum = 0;
      d[k][i][j] = sum;
      i += di[k];
      j += dj[k];
      if (!di[k] && (dj[k] * j > dj[k] * ej)) {
        j = sj;
        i++;
        sum = 0;
      }
      if (!dj[k] && (di[k] * i > di[k] * ei)) {
        i = si;
        j++;
        sum = 0;
      }
    }
  }
  int x, y, b;
  for (int l = 0; l < q; l++) {
    scanf("%i", &b);
    scanf("%i", &x);
    scanf("%i", &y);
    x--;
    y--;
    if (b - 1) {
      int best = 0;
      int res;
      for (int k = 0; k < 4; k++) {
        int i = x;
        int j = y;
        if (di[k]) {
          p[j] = d[k][i][j];
          int cmin = p[j];
          for (int f = j; f < m; f++) {
            if (d[k][i][f] < cmin) cmin = d[k][i][f];
            p[f] = cmin;
          }
          cmin = p[j];
          for (int f = j; f >= 0; f--) {
            if (d[k][i][f] < cmin) cmin = d[k][i][f];
            p[f] = cmin;
          }
          res = solve(j, 1);
        } else {
          p[i] = d[k][i][j];
          int cmin = p[i];
          for (int f = i; f < n; f++) {
            if (d[k][f][j] < cmin) cmin = d[k][f][j];
            p[f] = cmin;
          }
          cmin = p[i];
          for (int f = i; f >= 0; f--) {
            if (d[k][f][j] < cmin) cmin = d[k][f][j];
            p[f] = cmin;
          }
          res = solve(i, 0);
        }
        if (res > best) best = res;
      }
      printf("%i\n", best);
    } else {
      t[x][y] ^= 1;
      for (int k = 0; k < 4; k++) {
        int i = !di[k] * x + di[k] * di[k] * ((n - 1) * (1 - di[k]) / 2);
        int j = !dj[k] * y + dj[k] * dj[k] * ((m - 1) * (1 - dj[k]) / 2);
        int sum = 0;
        while (i >= 0 && i < n && j >= 0 && j < m) {
          if (t[i][j])
            sum += t[i][j];
          else
            sum = 0;
          d[k][i][j] = sum;
          i += di[k];
          j += dj[k];
        }
      }
    }
  }
  return 0;
}
