#include "triangles.h"

using namespace std;

vector <vector <int> > solve(int n) {
    if (n == 4) {
        vector <Triangle> trigs;
        trigs.emplace_back(0, 1, 2);
        trigs.emplace_back(0, 1, 3);
        trigs.emplace_back(0, 2, 3);
        trigs.emplace_back(1, 2, 3);
        for (int a = 0; a < n - 1; a++) {
            for (int b = a + 1; b < n; b++) {
                int c = 0, d = 0;
                for (int i = 0; i < n; i++) {
                    if (i != a && i != b) {
                        if (c == 0) {
                            c = i;
                        }
                        else {
                            d = i;
                        }
                    }
                    if (compare({trigs[a], trigs[b]}, {trigs[c], trigs[d]}) == 0) {
                        vector <int> v1 = {trigs[a].i, trigs[a].j, trigs[a].k};
                        vector <int> v2 = {trigs[b].i, trigs[b].j, trigs[b].k};
                        return {v1, v2};
                    }
                }
            }
        }
        int mx = -1;
        for (int i = 0; i < n; i++) {
            bool check = 1;
            for (int j = 0; j < n; j++) {
                if (j == i) continue;
                if (compare({trigs[i]}, {trigs[j]}) != 1) {
                    check = 0;
                }
            }
            if (check) {
                mx = i;
                break;
            }
        }
        vector <int> mv;
        for (int i = 0; i < n; i++) {
            if (i != mx) {
                mv.push_back(i);
            }
        }
        vector <int> v[3];
        for (int i = 0; i < n - 1; i++) {
            int tid = mv[i];
            Triangle T = trigs[tid];
            v[i] = {T.i, T.j, T.k};
        }
        return {v[0], v[1], v[2]};
    }
}