#include "iostream"
#include "triangles.h"
#include <vector>
#include <set>

using namespace std;


std::vector<std::vector<int>> solve(int n) {
    vector<Triangle> triangles;
    for (int i1 = 0; i1 < n; i1++) {
        for (int i2 = i1 + 1; i2 < n; i2++) {
            for (int i3 = i2 + 1; i3 < n; i3++) {
                triangles.push_back(Triangle(i1, i2, i3));
            }
        }
    }
    int ind = 0;
    int sz = (int)triangles.size();
    for (int i = 0; i < sz; i++) {
        vector<Triangle> left;
        left.push_back(triangles[i]);
        vector<Triangle> right;
        right.push_back(triangles[ind]);
        if (compare(left, right) == 1) {
            ind = i;
        }
    }
    for (int cent = 0; cent < n; cent++) {
        vector<Triangle> our;
        for (int p1 = 0; p1 < n; p1++) {
            for (int p2 = p1 + 1; p2 < n; p2++) {
                if (p1 != cent && p2 != cent) {
                    our.push_back(Triangle(cent, p1, p2));
                }
            }
        }
        int ch = 1;
        for (auto& T : our) {
            if (compare(T, triangles[ind]) == 0) {
                ch = 0;
                break;
            }
        }
        if (ch) {
            vector<vector<int>> ans;
            for (int p1 = 0; p1 < n; p1++) {
                for (int p2 = p1 + 1; p2 < n; p2++) {
                    if (p1 != cent && p2 != cent) {
                        ans.push_back({ cent, p1, p2 });
                    }
                }
            }
            return ans;
        }
    }
}
