#include "triangles.h"
#include <bits/stdc++.h>

using namespace std;

bool cmp(const vector<Triangle> &x, const vector<Triangle> &y) {
    return compare(x, y) == -1;
}

std::vector<std::vector<int>> solve(int n) {
    if (n != 4) {
        exit(228);
    }
    vector<vector<Triangle> > vec;
    vec.push_back({{0, 1, 2}});
    vec.push_back({{0, 1, 3}});
    vec.push_back({{0, 2, 3}});
    vec.push_back({{1, 2, 3}});
    sort(vec.begin(), vec.end(), cmp);

    vector<Triangle> left = {vec[0][0], vec[1][0], vec[2][0]};
    vector<Triangle> right = {vec[3][0]};
    int cm = compare(left, right);

    if (cm == 0) {
        vector<vector<int> > res;
        res.push_back({vec[0][0].i, vec[0][0].j, vec[0][0].k});
        res.push_back({vec[1][0].i, vec[1][0].j, vec[1][0].k});
        res.push_back({vec[2][0].i, vec[2][0].j, vec[2][0].k});
        // res.push_back({vec[3][0].i, vec[3][0].j, vec[3][0].k});
        return res;
    } else {
        vector<vector<int> > res;
        left = {vec[0][0], vec[3][0]};
        right = {vec[1][0], vec[2][0]};
        cm = compare(left, right);
        if (cm == 0) {
            res.push_back({vec[0][0].i, vec[0][0].j, vec[0][0].k});
            res.push_back({vec[3][0].i, vec[3][0].j, vec[3][0].k});
        } else {
            res.push_back({vec[1][0].i, vec[1][0].j, vec[1][0].k});
            res.push_back({vec[3][0].i, vec[3][0].j, vec[3][0].k});
        }
        return res;
    }
}
