#include <bits/stdc++.h>
using namespace std;
int m, n, q;
int a[1010][1010];
int L[1010][1010];
int R[1010][1010];
int T[1010][1010];
int D[1010][1010];
int Left[1010];
int Right[1010];
int top[1010];
int down[1010];
int c[1010];
int main() {
  ios::sync_with_stdio(false);
  cin >> m >> n >> q;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
      if (a[i][j] == 0) {
        L[i][j] = 0;
        T[i][j] = 0;
      } else {
        L[i][j] = L[i][j - 1] + 1;
        T[i][j] = T[i - 1][j] + 1;
      }
    }
  for (int i = m; i >= 1; i--)
    for (int j = n; j >= 1; j--)
      if (a[i][j] == 0) {
        R[i][j] = 0;
        D[i][j] = 0;
      } else {
        R[i][j] = R[i][j + 1] + 1;
        D[i][j] = D[i + 1][j] + 1;
      }
  int p, x, y;
  for (int kk = 1; kk <= q; kk++) {
    cin >> p >> x >> y;
    if (p == 1) {
      a[x][y] = 1 - a[x][y];
      for (int i = x; i <= m; i++)
        if (a[i][y] == 0)
          T[i][y] = 0;
        else
          T[i][y] = T[i - 1][y] + 1;
      for (int i = x; i >= 1; i--)
        if (a[i][y] == 0)
          D[i][y] = 0;
        else
          D[i][y] = D[i + 1][y] + 1;
      for (int j = y; j <= n; j++)
        if (a[x][j] == 0)
          L[x][j] = 0;
        else
          L[x][j] = L[x][j - 1] + 1;
      for (int j = y; j >= 1; j--)
        if (a[x][j] == 0)
          R[x][j] = 0;
        else
          R[x][j] = R[x][j + 1] + 1;
    } else {
      if (a[x][y] == 0)
        cout << 0 << "\n";
      else {
        int res = 0;
        for (int j = 1; j <= n; j++) c[j] = T[x][j];
        c[0] = -1000000;
        c[n + 1] = -1000000;
        for (int j = 1; j <= n; j++) {
          int k = j - 1;
          while (c[k] >= c[j]) k = Left[k] - 1;
          Left[j] = k + 1;
        }
        for (int j = n; j >= 1; j--) {
          int k = j + 1;
          while (c[k] >= c[j]) k = Right[k] + 1;
          Right[j] = k - 1;
        }
        for (int i = 1; i <= n; i++)
          if (Left[i] <= y && y <= Right[i])
            res = max(res, (Right[i] - Left[i] + 1) * c[i]);
        for (int j = 1; j <= n; j++) c[j] = D[x][j];
        c[0] = -1000000;
        c[n + 1] = -1000000;
        for (int j = 1; j <= n; j++) {
          int k = j - 1;
          while (c[k] >= c[j]) k = Left[k] - 1;
          Left[j] = k + 1;
        }
        for (int j = n; j >= 1; j--) {
          int k = j + 1;
          while (c[k] >= c[j]) k = Right[k] + 1;
          Right[j] = k - 1;
        }
        for (int i = 1; i <= n; i++)
          if (Left[i] <= y && y <= Right[i])
            res = max(res, (Right[i] - Left[i] + 1) * c[i]);
        c[0] = -1000000;
        c[m + 1] = -1000000;
        for (int i = 1; i <= m; i++) c[i] = L[i][y];
        for (int i = 1; i <= m; i++) {
          int k = i - 1;
          while (c[i] <= c[k]) k = top[k] - 1;
          top[i] = k + 1;
        }
        for (int i = m; i >= 1; i--) {
          int k = i + 1;
          while (c[i] <= c[k]) k = down[k] + 1;
          down[i] = k - 1;
        }
        for (int i = 1; i <= m; i++)
          if (top[i] <= x && x <= down[i])
            res = max(res, (down[i] - top[i] + 1) * c[i]);
        c[0] = -1000000;
        c[m + 1] = -1000000;
        for (int i = 1; i <= m; i++) c[i] = R[i][y];
        for (int i = 1; i <= m; i++) {
          int k = i - 1;
          while (c[i] <= c[k]) k = top[k] - 1;
          top[i] = k + 1;
        }
        for (int i = m; i >= 1; i--) {
          int k = i + 1;
          while (c[i] <= c[k]) k = down[k] + 1;
          down[i] = k - 1;
        }
        for (int i = 1; i <= m; i++)
          if (top[i] <= x && x <= down[i])
            res = max(res, (down[i] - top[i] + 1) * c[i]);
        cout << res << "\n";
      }
    }
  }
  return 0;
}
