OI XXXIII - bag

// https://sio2.mimuw.edu.pl/c/oi33-1/p/

#include <bits/stdc++.h>

// #define GARY_DBG
#define GARY_LIB

constexpr int sizik = 1000 * 1001;

#define ar std::array

#define int int64_t

typedef std::vector<std::vector<int>> _kra;
int getter[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};

void solve() {
    int n;
    std::cin >> n;

    std::vector<ar<int, 3>> v(n);
    for (auto& [a, b, c] : v) {
        std::cin >> a >> b >> c;
    }

    int ans = 0;
    for (int x = 0; x < 6; x++) {
        int uy[3]{INT64_MAX, INT64_MAX, INT64_MAX};
        for (auto& a : v) {
            std::sort(a.begin(), a.end());
            ar<int, 3> b = a;
            b[0] = a[getter[x][0]];
            b[1] = a[getter[x][1]];
            b[2] = a[getter[x][2]];
            a = b;
            for (int k = 0; k < 3; k++) {
                uy[k] = std::min(uy[k], b[k]);
            }
        }
        ans = std::max(ans, uy[0] * uy[1] * uy[2]);
    }
    std::cout << ans << '\n';
}

int32_t main() {
#ifndef GARY_DBG
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
#endif

    int t = 1;
    // std::cin >> t;

    for (; t > 0; t--) {
        solve();
    }

    return 0;
}