#include <bits/stdc++.h>
using namespace std;
int T[1010][1010];
int FU[1010][1010];
int FD[1010][1010];
int FL[1010][1010];
int FR[1010][1010];
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j) scanf("%d", &T[i][j]);
  for (int i = (1); i <= (n); ++i) {
    for (int j = (1); j <= (m); ++j) {
      if (T[i][j] == 0)
        FL[i][j] = j;
      else
        FL[i][j] = FL[i][j - 1];
      if (T[i][j] == 0)
        FU[i][j] = i;
      else
        FU[i][j] = FU[i - 1][j];
    }
  }
  for (int i = (1); i <= (n); ++i) {
    FR[i][m + 1] = m + 1;
    FD[i][m + 1] = i;
    FU[i][m + 1] = i;
    FU[i][0] = i;
    FD[i][0] = i;
  }
  for (int j = (1); j <= (m); ++j) {
    FD[n + 1][j] = n + 1;
    FR[n + 1][j] = j;
    FL[n + 1][j] = j;
    FR[0][j] = j;
    FL[0][j] = j;
  }
  for (int i = n; i > 0; i--)
    for (int j = m; j > 0; j--) {
      if (T[i][j] == 0)
        FR[i][j] = j;
      else
        FR[i][j] = FR[i][j + 1];
      if (T[i][j] == 0)
        FD[i][j] = i;
      else
        FD[i][j] = FD[i + 1][j];
    }
  for (int i = (0); i <= (int(q) - 1); ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1) {
      T[b][c] = (T[b][c] + 1) % 2;
      for (int i = (1); i <= (n); ++i)
        if (T[i][c] == 0)
          FU[i][c] = i;
        else
          FU[i][c] = FU[i - 1][c];
      for (int i = n; i > 0; i--)
        if (T[i][c] == 0)
          FD[i][c] = i;
        else
          FD[i][c] = FD[i + 1][c];
      for (int j = (1); j <= (m); ++j)
        if (T[b][j] == 0)
          FL[b][j] = j;
        else
          FL[b][j] = FL[b][j - 1];
      for (int j = m; j > 0; j--)
        if (T[b][j] == 0)
          FR[b][j] = j;
        else
          FR[b][j] = FR[b][j + 1];
    } else {
      int ans = 0;
      int curr = FD[b][c];
      int R = c + 1;
      int L = c - 1;
      int szer = 1;
      while (szer * (curr - b) != 0) {
        ans = max(ans, (curr - b) * szer);
        if (FD[b][R] > FD[b][L]) {
          curr = min(curr, FD[b][R]);
          szer++;
          R++;
        } else {
          szer++;
          curr = min(curr, FD[b][L]);
          L--;
        }
      }
      curr = FU[b][c];
      R = c + 1;
      L = c - 1;
      szer = 1;
      while (szer * (b - curr) != 0) {
        ans = max(ans, (b - curr) * szer);
        if (FU[b][R] < FU[b][L]) {
          curr = max(curr, FU[b][R]);
          szer++;
          R++;
        } else {
          szer++;
          curr = max(curr, FU[b][L]);
          L--;
        }
      }
      curr = FL[b][c];
      int U = b - 1;
      int D = b + 1;
      szer = 1;
      while (szer * (c - curr) != 0) {
        ans = max(ans, (c - curr) * szer);
        if (FL[D][c] < FL[U][c]) {
          curr = max(curr, FL[D][c]);
          szer++;
          D++;
        } else {
          szer++;
          curr = max(curr, FL[U][c]);
          U--;
        }
      }
      curr = FR[b][c];
      U = b - 1;
      D = b + 1;
      szer = 1;
      while (szer * (curr - c) != 0) {
        ans = max(ans, (curr - c) * szer);
        if (FR[D][c] > FR[U][c]) {
          curr = min(curr, FR[D][c]);
          szer++;
          D++;
        } else {
          szer++;
          curr = min(curr, FR[U][c]);
          U--;
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
