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

using namespace std;
using ll = long long;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()

std::vector<std::vector<int>> solve(int n) {
    vector<int> cntmid(n);
    for (int i = 0; i < 4; i++) {
        for (int j = i + 1; j < 4; j++) {
            vector<Triangle> t1, t2;
            vector<int> nij;
            for (int k = 0; k < 4; k++) {
                if (k != i && k != j) nij.pb(k);
            }
            for(int u : nij) t1.pb(Triangle(i, j, u));
            t2.pb(Triangle(nij[0], nij[1], i));
            t2.pb(Triangle(nij[0], nij[1], j));
            int res = compare(t1, t2);
            if (res == 0) {
                vector<vector<int>> ans = {{i, j, nij[0]}, {i, j, nij[1]}};
                return ans;
            } else {
                if (res == -1) {
                    cntmid[i]++; cntmid[j]++;
                } else {
                    cntmid[nij[0]]++; cntmid[nij[1]]++;
                }
            }
        }
    }

    int pos = 0;
    for (int j = 1; j < 4;j ++) if (cntmid[j] > cntmid[pos]) pos = j;

    vector<vector<int>> ans;
    for (int i = 0; i < 4; i++) {
        if (i == pos) continue;
        for (int j = i + 1; j < 4; j++) {
            if (j == pos) continue;
            ans.pb({i, j, pos});
        }
    }
    return ans;
}
