#include "triangles.h"
#include <set>
#include <algorithm>

using namespace std;

#define all(v) v.begin(), v.end()
#define len(v) (int)v.size()

set<Triangle>ans;

bool operator<(Triangle a, Triangle b) {
    vector<int>a1 = {a.i, a.j, a.k};
    vector<int>b1 = {b.i, b.j, b.k};
    sort(all(a1));
    sort(all(b1));
    return a1 < b1;
}

void f(int x, int y, int z, int n) {
    if (ans.find({x, y, z}) != ans.end()) return;
    for (int i = 0; i < n; ++i) {
        if (i == x || i == y || i == z) {
            continue;
        }
        if (compare({{x, y, z}}, {{x, y, i}, {x, z, i}, {y, z, i}}) == 0) {
            f(x, y, i, n);
            f(x, z, i, n);
            f(y, z, i, n);
            return;
        }
    }
    ans.emplace(x, y, z);
}

vector<vector<int>> solve(int n) {
    for (int j = 1; j < n; ++j) {
        for (int k = j + 1; k < n; ++k) {
            f(0, j, k, n);
        }
    }
    vector<vector<int>>v;
    for (auto &[i, j, k] : ans) {
        v.push_back({i, j, k});
    }
    return v;
}
