#include <bits/stdc++.h>
template <typename T>
T nextInt() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * p;
}
const int maxN = (int)1e3 + 10;
const int INF = (int)1e7;
const int mod = (int)1e9 + 7;
const long long LLINF = (long long)1e18;
int a[maxN][maxN];
std::vector<std::vector<int> > up;
std::vector<std::vector<int> > down;
std::vector<std::vector<int> > left;
std::vector<std::vector<int> > right;
int n, m, q;
struct dsu {
  int n;
  int point;
  int p[maxN];
  int sz[maxN];
  bool active[maxN];
  int maxSize;
  dsu(int n, int point) : n(n), maxSize(1), point(point) {
    for (int i = 1; i <= n; ++i) {
      p[i] = i;
      sz[i] = 1;
      active[i] = false;
    }
  }
  int ancestor(int x) {
    if (p[x] == x) return x;
    return p[x] = ancestor(p[x]);
  }
  void unite(int x, int y) {
    x = ancestor(x);
    y = ancestor(y);
    if (x == y) return;
    p[x] = y;
    sz[y] += sz[x];
    if (ancestor(point) == y) maxSize = std::max(maxSize, sz[y]);
  }
  void activate(int idx) {
    active[idx] = true;
    if (idx >= 2 && active[idx - 1]) unite(idx - 1, idx);
    if (idx < n && active[idx + 1]) unite(idx, idx + 1);
  }
};
std::vector<int> cnt[maxN];
void countingSort(int n, int *array, std::pair<int, int> *result) {
  for (int i = 1; i <= n; ++i) {
    cnt[array[i]].push_back(i);
  }
  int ptr = 1;
  for (int i = 0; i < maxN; ++i) {
    while (!cnt[i].empty()) {
      result[ptr++] = std::make_pair(i, cnt[i].back());
      cnt[i].pop_back();
    }
  }
}
std::pair<int, int> temp[maxN];
int solveRectangleInHistogram(int n, int *array, int point) {
  dsu DSU(n, point);
  countingSort(n, array, temp);
  int result = 0;
  bool wasPoint = false;
  for (int i = n; i >= 1; --i) {
    DSU.activate(temp[i].second);
    if (temp[i].second == point) wasPoint = true;
    if (wasPoint) result = std::max(result, DSU.maxSize * temp[i].first);
  }
  return result;
}
void updateRow(int x) {
  for (int j = 1; j <= m; ++j) {
    left[x][j] = (a[x][j] == 0 ? 0 : left[x][j - 1] + 1);
  }
  for (int j = m; j >= 1; --j) {
    right[x][j] = (a[x][j] == 0 ? 0 : right[x][j + 1] + 1);
  }
}
void updateCol(int y) {
  for (int i = 1; i <= n; ++i) {
    up[i][y] = (a[i][y] == 0 ? 0 : up[i - 1][y] + 1);
  }
  for (int i = n; i >= 1; --i) {
    down[i][y] = (a[i][y] == 0 ? 0 : down[i + 1][y] + 1);
  }
}
void getLongestInAColumn(int x, int y, int &l, int &r) {
  l = x - 1;
  while (l >= 1 && a[l][y] == 1) l--;
  r = x;
  while (r <= n && a[r][y] == 1) r++;
  l++;
  r--;
}
void getLongestInARow(int x, int y, int &l, int &r) {
  l = y - 1;
  while (l >= 1 && a[x][l] == 1) l--;
  r = y;
  while (r <= m && a[x][r] == 1) r++;
  l++;
  r--;
}
int *getSubsequenceFromColumn(const std::vector<std::vector<int> > &array,
                              int y, int l, int r) {
  int *res = new int[(r - l + 1) + 1];
  for (int i = l; i <= r; ++i) {
    res[i - l + 1] = array[i][y];
  }
  return res;
}
int *getSubsequenceFromRow(const std::vector<std::vector<int> > &array, int x,
                           int l, int r) {
  int *res = new int[(r - l + 1) + 1];
  for (int i = l; i <= r; ++i) {
    res[i - l + 1] = array[x][i];
  }
  return res;
}
int main() {
  n = nextInt<int>();
  m = nextInt<int>();
  q = nextInt<int>();
  srand(time(NULL));
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      a[i][j] = nextInt<int>();
    }
  }
  right.resize(n + 2, std::vector<int>(m + 2));
  left.resize(n + 2, std::vector<int>(m + 2));
  down.resize(n + 2, std::vector<int>(m + 2));
  up.resize(n + 2, std::vector<int>(m + 2));
  for (int i = 1; i <= n; ++i) {
    updateRow(i);
  }
  for (int j = 1; j <= m; ++j) {
    updateCol(j);
  }
  for (int qq = 0; qq < q; ++qq) {
    int type, x, y;
    type = nextInt<int>();
    x = nextInt<int>();
    y = nextInt<int>();
    if (type == 1) {
      a[x][y] ^= 1;
      updateRow(x);
      updateCol(y);
    } else {
      if (a[x][y] == 0) {
        printf("%d\n", 0);
        continue;
      }
      int result = 0;
      int l, r;
      getLongestInAColumn(x, y, l, r);
      result = std::max(
          result,
          solveRectangleInHistogram(
              r - l + 1, getSubsequenceFromColumn(left, y, l, r), x - l + 1));
      result = std::max(
          result,
          solveRectangleInHistogram(
              r - l + 1, getSubsequenceFromColumn(right, y, l, r), x - l + 1));
      getLongestInARow(x, y, l, r);
      result = std::max(
          result,
          solveRectangleInHistogram(
              r - l + 1, getSubsequenceFromRow(up, x, l, r), y - l + 1));
      result = std::max(
          result,
          solveRectangleInHistogram(
              r - l + 1, getSubsequenceFromRow(down, x, l, r), y - l + 1));
      printf("%d\n", result);
    }
  }
  return 0;
}
