#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int arr[1005][1005];
int lf[1005][1005], rht[1005][1005], top[1005][1005], bottom[1005][1005];
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      scanf("%d", &arr[i][j]);
    }
  }
  for (int x = 1; x <= n; ++x) {
    for (int j = 1; j <= m; ++j) {
      lf[x][j] = arr[x][j - 1] == 1 ? lf[x][j - 1] + 1 : 0;
    }
    for (int j = m; j >= 1; --j) {
      rht[x][j] = arr[x][j + 1] == 1 ? rht[x][j + 1] + 1 : 0;
    }
  }
  for (int y = 1; y <= m; ++y) {
    for (int i = 1; i <= n; ++i) {
      top[i][y] = arr[i - 1][y] == 1 ? top[i - 1][y] + 1 : 0;
    }
    for (int i = n; i >= 1; --i) {
      bottom[i][y] = arr[i + 1][y] == 1 ? bottom[i + 1][y] + 1 : 0;
    }
  }
  int op, x, y;
  for (int t = 0; t < q; ++t) {
    scanf("%d %d %d", &op, &x, &y);
    if (op == 1) {
      arr[x][y] = 1 - arr[x][y];
      for (int j = 1; j <= m; ++j) {
        lf[x][j] = arr[x][j - 1] == 1 ? lf[x][j - 1] + 1 : 0;
      }
      for (int j = m; j >= 1; --j) {
        rht[x][j] = arr[x][j + 1] == 1 ? rht[x][j + 1] + 1 : 0;
      }
      for (int i = 1; i <= n; ++i) {
        top[i][y] = arr[i - 1][y] == 1 ? top[i - 1][y] + 1 : 0;
      }
      for (int i = n; i >= 1; --i) {
        bottom[i][y] = arr[i + 1][y] == 1 ? bottom[i + 1][y] + 1 : 0;
      }
    } else {
      int best = 0;
      int tmp = 0;
      int mx1 = 1e9, mx2 = 1e9;
      for (int j = y; j <= m; ++j) {
        if (arr[x][j] == 0) {
          break;
        }
        int first = top[x][j];
        int second = bottom[x][j];
        mx1 = min(mx1, first);
        mx2 = min(mx2, second);
        tmp = max(tmp, (j - y + 1) * (mx1 + mx2 + 1));
      }
      best = max(best, tmp);
      tmp = 0;
      mx1 = 1e9, mx2 = 1e9;
      for (int j = y; j >= 1; --j) {
        if (arr[x][j] == 0) {
          break;
        }
        int first = top[x][j];
        int second = bottom[x][j];
        mx1 = min(mx1, first);
        mx2 = min(mx2, second);
        tmp = max(tmp, (y - j + 1) * (mx1 + mx2 + 1));
      }
      best = max(best, tmp);
      tmp = 0;
      mx1 = 1e9, mx2 = 1e9;
      for (int i = x; i <= n; ++i) {
        if (arr[i][y] == 0) {
          break;
        }
        int first = lf[i][y];
        int second = rht[i][y];
        mx1 = min(mx1, first);
        mx2 = min(mx2, second);
        tmp = max(tmp, (i - x + 1) * (mx1 + mx2 + 1));
      }
      best = max(best, tmp);
      tmp = 0;
      mx1 = 1e9, mx2 = 1e9;
      for (int i = x; i >= 1; --i) {
        if (arr[i][y] == 0) {
          break;
        }
        int first = lf[i][y];
        int second = rht[i][y];
        mx1 = min(mx1, first);
        mx2 = min(mx2, second);
        tmp = max(tmp, (x - i + 1) * (mx1 + mx2 + 1));
      }
      best = max(best, tmp);
      printf("%d\n", best);
    }
  }
}
