// #include </home/olymp/work/untitled1/debug.h>
// #define M(x) #x

#include <bits/stdc++.h>
#include "triangles.h"
#pragma GCC optimize("Ofast")

using namespace std;
using ll = long long;
//
// # define len(x) ((ll) x.size())
// const ll inf = 1e18;

// delete
// struct Triangle {
//     int i, j, k;
//     Triangle() = default;
//     Triangle(int i_, int j_, int k_) : i(i_), j(j_), k(k_) {}
// };
//
// int compare(const std::vector<Triangle>& left, const std::vector<Triangle>& right);
// delete

std::vector<std::vector<int>> solve(int n) {
    vector<Triangle> tr;
    for (ll i = 0; i < 4; ++i) {
        for (ll j = i + 1; j < 4; ++j) {
            for (ll k = j + 1; k < 4; ++k) {
                tr.push_back(Triangle(i, j, k));
            }
        }
    }
    sort(tr.begin(), tr.end(), [&](const Triangle& ax, const Triangle& bx) -> bool {
        return compare({ax}, {bx}) < 0;
    });

    vector<int> ids = {tr.back().i, tr.back().j, tr.back().k};

    int center = -1;
    for (ll i = 0; i < 4; ++i) {
        if (find(ids.begin(), ids.end(), i) == ids.end()) {
            center = i;
            break;
        }
    }
    if (compare({Triangle(ids[0], ids[1], ids[2])}, {Triangle(center, ids[0], ids[1]), Triangle(center, ids[1], ids[2]), Triangle(center, ids[0], ids[2])})) {
        return {{center, ids[0], ids[1]}, {center, ids[1], ids[2]}, {center, ids[0], ids[2]}};
    }
    return {{ids[0], ids[1], ids[2]}};
}

// int main() {
//     ios::sync_with_stdio(false);
//     cin.tie(nullptr);
//
//     return 0;
// }