#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> a(n, vector<int>(m));
  vector<vector<array<int, 4>>> pref(n, vector<array<int, 4>>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 0) {
        pref[i][j][0] = 0;
      } else {
        pref[i][j][0] = 1 + (j > 0 ? pref[i][j - 1][0] : 0);
      }
    }
    for (int j = m - 1; j >= 0; j--) {
      if (a[i][j] == 0) {
        pref[i][j][1] = 0;
      } else {
        pref[i][j][1] = 1 + (j < m - 1 ? pref[i][j + 1][1] : 0);
      }
    }
  }
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      if (a[i][j] == 0) {
        pref[i][j][3] = 0;
      } else {
        pref[i][j][3] = 1 + (i > 0 ? pref[i - 1][j][3] : 0);
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (a[i][j] == 0) {
        pref[i][j][2] = 0;
      } else {
        pref[i][j][2] = 1 + (i < n - 1 ? pref[i + 1][j][2] : 0);
      }
    }
  }
  auto upd = [&](int x, int y) {
    a[x][y] = 1 - a[x][y];
    for (int j = 0; j < m; j++) {
      if (a[x][j] == 0) {
        pref[x][j][0] = 0;
      } else {
        pref[x][j][0] = 1 + (j > 0 ? pref[x][j - 1][0] : 0);
      }
    }
    for (int j = m - 1; j >= 0; j--) {
      if (a[x][j] == 0) {
        pref[x][j][1] = 0;
      } else {
        pref[x][j][1] = 1 + (j < m - 1 ? pref[x][j + 1][1] : 0);
      }
    }
    for (int i = 0; i < n; i++) {
      if (a[i][y] == 0) {
        pref[i][y][3] = 0;
      } else {
        pref[i][y][3] = 1 + (i > 0 ? pref[i - 1][y][3] : 0);
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (a[i][y] == 0) {
        pref[i][y][2] = 0;
      } else {
        pref[i][y][2] = 1 + (i < n - 1 ? pref[i + 1][y][2] : 0);
      }
    }
  };
  auto query = [&](int x, int y) {
    int ans = 0;
    stack<array<int, 2>> st;
    vector<int> left(m), right(m);
    for (int j = 0; j < m; j++) {
      while ((int)st.size() && st.top()[0] >= pref[x][j][3]) {
        st.pop();
      }
      if ((int)st.size() == 0) {
        left[j] = -1;
      } else {
        left[j] = st.top()[1];
      }
      st.push({pref[x][j][3], j});
    }
    while ((int)st.size()) {
      st.pop();
    }
    for (int j = m - 1; j >= 0; j--) {
      while ((int)st.size() && st.top()[0] >= pref[x][j][3]) {
        st.pop();
      }
      if ((int)st.size() == 0) {
        right[j] = m;
      } else {
        right[j] = st.top()[1];
      }
      st.push({pref[x][j][3], j});
    }
    while ((int)st.size()) {
      st.pop();
    }
    for (int j = 0; j < m; j++) {
      if (left[j] < y && right[j] > y) {
        ans = max(ans, pref[x][j][3] * (right[j] - left[j] - 1));
      }
    }
    for (int j = 0; j < m; j++) {
      while ((int)st.size() && st.top()[0] >= pref[x][j][2]) {
        st.pop();
      }
      if ((int)st.size() == 0) {
        left[j] = -1;
      } else {
        left[j] = st.top()[1];
      }
      st.push({pref[x][j][2], j});
    }
    while ((int)st.size()) {
      st.pop();
    }
    for (int j = m - 1; j >= 0; j--) {
      while ((int)st.size() && st.top()[0] >= pref[x][j][2]) {
        st.pop();
      }
      if ((int)st.size() == 0) {
        right[j] = m;
      } else {
        right[j] = st.top()[1];
      }
      st.push({pref[x][j][2], j});
    }
    while ((int)st.size()) {
      st.pop();
    }
    for (int j = 0; j < m; j++) {
      if (left[j] < y && right[j] > y) {
        ans = max(ans, pref[x][j][2] * (right[j] - left[j] - 1));
      }
    }
    vector<int> up(n), down(n);
    for (int i = 0; i < n; i++) {
      while ((int)st.size() && st.top()[0] >= pref[i][y][1]) {
        st.pop();
      }
      if ((int)st.size() == 0) {
        up[i] = -1;
      } else {
        up[i] = st.top()[1];
      }
      st.push({pref[i][y][1], i});
    }
    while ((int)st.size()) {
      st.pop();
    }
    for (int i = n - 1; i >= 0; i--) {
      while ((int)st.size() && st.top()[0] >= pref[i][y][1]) {
        st.pop();
      }
      if ((int)st.size() == 0) {
        down[i] = n;
      } else {
        down[i] = st.top()[1];
      }
      st.push({pref[i][y][1], i});
    }
    while ((int)st.size()) {
      st.pop();
    }
    for (int i = 0; i < n; i++) {
      if (down[i] > x && up[i] < x) {
        ans = max(ans, pref[i][y][1] * (down[i] - up[i] - 1));
      }
    }
    for (int i = 0; i < n; i++) {
      while ((int)st.size() && st.top()[0] >= pref[i][y][0]) {
        st.pop();
      }
      if ((int)st.size() == 0) {
        up[i] = -1;
      } else {
        up[i] = st.top()[1];
      }
      st.push({pref[i][y][0], i});
    }
    while ((int)st.size()) {
      st.pop();
    }
    for (int i = n - 1; i >= 0; i--) {
      while ((int)st.size() && st.top()[0] >= pref[i][y][0]) {
        st.pop();
      }
      if ((int)st.size() == 0) {
        down[i] = n;
      } else {
        down[i] = st.top()[1];
      }
      st.push({pref[i][y][0], i});
    }
    while ((int)st.size()) {
      st.pop();
    }
    for (int i = 0; i < n; i++) {
      if (down[i] > x && up[i] < x) {
        ans = max(ans, pref[i][y][0] * (down[i] - up[i] - 1));
      }
    }
    return ans;
  };
  while (q--) {
    int t, x, y;
    cin >> t >> x >> y;
    x--, y--;
    if (t == 1) {
      upd(x, y);
    } else {
      cout << query(x, y) << '\n';
    }
  }
  return 0;
}
