#include <bits/stdc++.h>
const int MAXN = 1005;
int dat[MAXN][MAXN];
int up[MAXN][MAXN], down[MAXN][MAXN];
int left[MAXN][MAXN], right[MAXN][MAXN];
int rows, cols;
void init() {
  memset(left, 0, sizeof(left));
  memset(right, 0, sizeof(right));
  memset(up, 0, sizeof(up));
  memset(down, 0, sizeof(down));
  for (int i = 1; i <= rows; i++) {
    for (int j = 1; j <= cols; j++) {
      left[i][j] = dat[i][j] ? (left[i][j - 1] + 1) : 0;
    }
    for (int j = cols; j >= 1; j--) {
      right[i][j] = dat[i][j] ? (right[i][j + 1] + 1) : 0;
    }
  }
  for (int j = 1; j <= cols; j++) {
    for (int i = 1; i <= rows; i++) {
      up[i][j] = dat[i][j] ? (up[i - 1][j] + 1) : 0;
    }
    for (int i = rows; i >= 1; i--) {
      down[i][j] = dat[i][j] ? (down[i + 1][j] + 1) : 0;
    }
  }
}
void modify(int x, int y) {
  dat[x][y] = !dat[x][y];
  left[x][y] = dat[x][y] ? (left[x][y - 1] + 1) : 0;
  for (int j = y + 1; j <= cols; j++) {
    if (dat[x][j] == 0) {
      break;
    }
    left[x][j] = left[x][j - 1] + 1;
  }
  right[x][y] = dat[x][y] ? (right[x][y + 1] + 1) : 0;
  for (int j = y - 1; j >= 1; j--) {
    if (dat[x][j] == 0) {
      break;
    }
    right[x][j] = right[x][j + 1] + 1;
  }
  up[x][y] = dat[x][y] ? (up[x - 1][y] + 1) : 0;
  for (int i = x + 1; i <= rows; i++) {
    if (dat[i][y] == 0) {
      break;
    }
    up[i][y] = up[i - 1][y] + 1;
  }
  down[x][y] = dat[x][y] ? (down[x + 1][y] + 1) : 0;
  for (int i = x - 1; i >= 1; i--) {
    if (dat[i][y] == 0) {
      break;
    }
    down[i][y] = down[i + 1][y] + 1;
  }
}
int query(int x, int y) {
  int r = 0;
  int top, bot;
  top = up[x][y];
  bot = down[x][y];
  for (int j = y; j >= 1; j--) {
    top = ((top) < (up[x][j]) ? (top) : (up[x][j]));
    bot = ((bot) < (down[x][j]) ? (bot) : (down[x][j]));
    if (top == 0 || bot == 0) {
      break;
    }
    r = ((r) > ((y - j + 1) * (top + bot - 1))
             ? (r)
             : ((y - j + 1) * (top + bot - 1)));
  }
  top = up[x][y];
  bot = down[x][y];
  for (int j = y; j <= cols; j++) {
    top = ((top) < (up[x][j]) ? (top) : (up[x][j]));
    bot = ((bot) < (down[x][j]) ? (bot) : (down[x][j]));
    if (top == 0 || bot == 0) {
      break;
    }
    r = ((r) > ((j - y + 1) * (top + bot - 1))
             ? (r)
             : ((j - y + 1) * (top + bot - 1)));
  }
  int lb, rb;
  lb = left[x][y];
  rb = right[x][y];
  for (int i = x; i >= 1; i--) {
    lb = ((lb) < (left[i][y]) ? (lb) : (left[i][y]));
    rb = ((rb) < (right[i][y]) ? (rb) : (right[i][y]));
    if (lb == 0 || rb == 0) {
      break;
    }
    r = ((r) > ((x - i + 1) * (lb + rb - 1)) ? (r)
                                             : ((x - i + 1) * (lb + rb - 1)));
  }
  lb = left[x][y];
  rb = right[x][y];
  for (int i = x; i <= rows; i++) {
    lb = ((lb) < (left[i][y]) ? (lb) : (left[i][y]));
    rb = ((rb) < (right[i][y]) ? (rb) : (right[i][y]));
    if (lb == 0 || rb == 0) {
      break;
    }
    r = ((r) > ((i - x + 1) * (lb + rb - 1)) ? (r)
                                             : ((i - x + 1) * (lb + rb - 1)));
  }
  return r;
}
int main() {
  int tst;
  scanf("%d %d %d", &rows, &cols, &tst);
  for (int i = 1; i <= rows; i++) {
    for (int j = 1; j <= cols; j++) {
      scanf("%d", &dat[i][j]);
    }
  }
  init();
  int opt, x, y;
  while (tst--) {
    scanf("%d %d %d", &opt, &x, &y);
    if (opt == 1) {
      modify(x, y);
    } else {
      printf("%d\n", query(x, y));
    }
  }
  return 0;
}
