#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
static inline int Rint() {
  struct X {
    int dig[256];
    X() {
      for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
      dig['-'] = 1;
    }
  };
  static X fuck;
  int s = 1, v = 0, c;
  for (; !fuck.dig[c = getchar()];)
    ;
  if (c == '-')
    s = 0;
  else if (fuck.dig[c])
    v = c ^ 48;
  for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48))
    ;
  return s ? v : -v;
}
template <typename T>
static inline void cmax(T& a, const T& b) {
  if (b > a) a = b;
}
template <typename T>
static inline void cmin(T& a, const T& b) {
  if (b < a) a = b;
}
const int maxn = 1005;
int L[maxn][maxn];
int R[maxn][maxn];
int U[maxn][maxn];
int D[maxn][maxn];
int data[maxn][maxn];
int n, m, q;
static inline void init() {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (data[i][j]) {
        L[i][j] = L[i][j - 1] + 1;
        U[i][j] = U[i - 1][j] + 1;
      }
  for (int i = n; i >= 1; --i)
    for (int j = m; j >= 1; --j)
      if (data[i][j]) {
        R[i][j] = R[i][j + 1] + 1;
        D[i][j] = D[i + 1][j] + 1;
      }
}
static inline void change(int x, int y) {
  data[x][y] ^= 1;
  for (int i = 1; i <= n; ++i)
    if (data[i][y])
      U[i][y] = U[i - 1][y] + 1;
    else
      U[i][y] = 0;
  for (int i = n; i >= 1; --i)
    if (data[i][y])
      D[i][y] = D[i + 1][y] + 1;
    else
      D[i][y] = 0;
  for (int j = 1; j <= m; ++j)
    if (data[x][j])
      L[x][j] = L[x][j - 1] + 1;
    else
      L[x][j] = 0;
  for (int j = m; j >= 1; --j)
    if (data[x][j])
      R[x][j] = R[x][j + 1] + 1;
    else
      R[x][j] = 0;
}
int cal(int* data, int cnt, int cover) {
  int stk[1024];
  int top = 0;
  int ret = 0;
  for (int i = 0; i < cnt; ++i) {
    while (top > 0 && data[i] <= data[stk[top - 1]]) {
      --top;
      int d = top ? i - stk[top - 1] - 1 : i;
      int flag = top ? cover > stk[top - 1] && cover < i : cover < i;
      int t = d * data[stk[top]];
      if (t > ret && flag) ret = t;
    }
    stk[top++] = i;
  }
  while (top > 0) {
    --top;
    int d = top ? cnt - stk[top - 1] - 1 : cnt;
    int flag = top ? cover > stk[top - 1] : 1;
    int t = d * data[stk[top]];
    if (t > ret && flag) ret = t;
  }
  return ret;
}
int main() {
  n = Rint(), m = Rint(), q = Rint();
  for (int i = (1); i < (n + 1); ++i)
    for (int j = (1); j < (m + 1); ++j) data[i][j] = Rint();
  init();
  while (q--) {
    int t = Rint(), x = Rint(), y = Rint();
    if (t == 1)
      change(x, y);
    else {
      if (data[x][y] == 0) {
        puts("0");
        continue;
      }
      int values[1024];
      int ans = 0;
      {
        int top = 0;
        int id = 0;
        for (int i = x; i >= 1 && data[i][y]; --i) values[top++] = R[i][y];
        reverse(values, values + top);
        id = top - 1;
        for (int i = x + 1; i <= n && data[i][y]; ++i) values[top++] = R[i][y];
        int t = cal(values, top, id);
        cmax(ans, t);
      }
      {
        int top = 0;
        int id = 0;
        for (int i = x; i >= 1 && data[i][y]; --i) values[top++] = L[i][y];
        reverse(values, values + top);
        id = top - 1;
        for (int i = x + 1; i <= n && data[i][y]; ++i) values[top++] = L[i][y];
        int t = cal(values, top, id);
        cmax(ans, t);
      }
      {
        int top = 0;
        int id = 0;
        for (int j = y; j >= 1 && data[x][j]; --j) values[top++] = U[x][j];
        reverse(values, values + top);
        id = top - 1;
        for (int j = y + 1; j <= m && data[x][j]; ++j) values[top++] = U[x][j];
        int t = cal(values, top, id);
        cmax(ans, t);
      }
      {
        int top = 0;
        int id = 0;
        for (int j = y; j >= 1 && data[x][j]; --j) values[top++] = D[x][j];
        reverse(values, values + top);
        id = top - 1;
        for (int j = y + 1; j <= m && data[x][j]; ++j) values[top++] = D[x][j];
        int t = cal(values, top, id);
        cmax(ans, t);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
