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

using namespace std;

std::vector<std::vector<int>> solve(int n) {
    assert(n == 4);
    for (int i = 0; i < 3; ++i) {
        vector<int> h = {3};
        for (int j = 0; j < 3; ++j) {
            if (j != i) {
                h.push_back(j);
            }
        }

        vector<int> l = {i, 3, h[1]}, r = {i, 3, h[2]};
        vector<Triangle> tri;
        for (auto v : {l, r, h}) {
            tri.push_back(Triangle(v[0], v[1], v[2]));
        }
        tri.push_back(Triangle(0, 1, 2));

//        for (int i = 0; i < 4; ++i) {
//            auto [x, y, z] = tri[i];
//            cerr << format("tri[{}] = {} {} {}\n", i, x, y, z);
//        }
//        cerr << "----\n";

        if (compare({tri[0], tri[1]}, {tri[2], tri[3]}) == 0) {
            return {l, r};
        }
    }

//    cerr << "panic!" << '\n';

    Triangle best = {};
    int left = -1;
    for (int i = 0; i < 4; ++i) {
        vector<int> t;
        for (int j = 0; j < 4; ++j) {
            if (i != j) {
                t.push_back(j);
            }
        }

        Triangle cur = {t[0], t[1], t[2]};

        if (left == -1) {
            best = cur;
            left = i;
        } else if (compare({best}, {cur}) == -1) {
            best = cur;
            left = i;
        }
    }

    vector<vector<int>> ans;
    for (int i = 0; i < 4; ++i) {
        for (int j = i + 1; j < 4; ++j) {
            if (i == left || j == left) continue;
            ans.push_back({left, i, j});
        }
    }

    return ans;
}
