#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int dp[maxn][maxn][4];
int now[maxn][maxn];
void set0(int x, int y, int dx, int dy, int ind, int k) {
  if (now[x][y] == 0) return;
  dp[x][y][ind] += k;
  set0(x + dx, y + dy, dx, dy, ind, k);
}
int get(int x, int y, int ind, int dx1, int dy1, int dx2, int dy2) {
  int xx1, yy1, xx2, yy2;
  xx1 = xx2 = x;
  yy1 = yy2 = y;
  int m = dp[x][y][ind], ans = m;
  while (m >= 1) {
    while (dp[xx1 + dx1][yy1 + dy1][ind] >= m) xx1 += dx1, yy1 += dy1;
    while (dp[xx2 + dx2][yy2 + dy2][ind] >= m) xx2 += dx2, yy2 += dy2;
    ans = max(ans, m * (abs(xx2 - xx1) + abs(yy1 - yy2) + 1));
    m--;
  }
  return ans;
}
void DEB(int n, int m) {
  int i, j, k;
  for (k = 0; k < 4; k++) {
    puts("\n");
    for (i = 1; i <= n; i++, puts(""))
      for (j = 1; j <= m; j++) printf("%d ", dp[i][j][k]);
  }
}
int main() {
  int n, m, i, j, k;
  int q;
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &now[i][j]);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++)
      if (now[i][j]) dp[i][j][3] = dp[i][j - 1][3] + 1;
    for (j = m; j >= 1; j--)
      if (now[i][j]) dp[i][j][1] = dp[i][j + 1][1] + 1;
  }
  for (j = 1; j <= m; j++) {
    for (i = 1; i <= n; i++)
      if (now[i][j]) dp[i][j][0] = dp[i - 1][j][0] + 1;
    for (i = n; i >= 1; i--)
      if (now[i][j]) dp[i][j][2] = dp[i + 1][j][2] + 1;
  }
  while (q--) {
    scanf("%d%d%d", &k, &i, &j);
    if (k == 1) {
      if (now[i][j]) {
        set0(i, j, -1, 0, 2, -dp[i][j][2]);
        set0(i, j, 0, 1, 3, -dp[i][j][3]);
        set0(i, j, 1, 0, 0, -dp[i][j][0]);
        set0(i, j, 0, -1, 1, -dp[i][j][1]);
        now[i][j] = 0;
      } else {
        now[i][j] = 1;
        set0(i, j, -1, 0, 2, dp[i + 1][j][2] + 1);
        set0(i, j, 0, 1, 3, dp[i][j - 1][3] + 1);
        set0(i, j, 1, 0, 0, dp[i - 1][j][0] + 1);
        set0(i, j, 0, -1, 1, dp[i][j + 1][1] + 1);
      }
    } else {
      int ans1 = get(i, j, 0, 0, -1, 0, 1);
      int ans2 = get(i, j, 1, -1, 0, 1, 0);
      int ans3 = get(i, j, 2, 0, -1, 0, 1);
      int ans4 = get(i, j, 3, -1, 0, 1, 0);
      printf("%d\n", max(max(ans1, ans2), max(ans3, ans4)));
    }
  }
}
