#include "triangles.h"
#include <cmath>

using namespace std;

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

Triangle exc(int i) {
    if (i == 0) return {1, 2, 3};
    if (i == 1) return {0, 2, 3};
    if (i == 2) return {0, 1, 3};
    return {0, 1, 2};
}

vector<vector<int>> solve(int n) {
    for (int i = 0; i < 4; ++i) {
        vector<Triangle> left = {exc(i)}, right;
        for (int j = 0; j < 4; ++j) {
            if (i == j) continue;
            right.push_back(exc(j));
        }
        if (compare(left, right) == 0) return inner(i);
    }
    const int c1 = compare({exc(0), exc(2)}, {{exc(1), exc(3)}});
    const int c2 = compare({exc(3), exc(2)}, {exc(1), exc(0)});
    if (c1 == 0)
        return {{1, 2, 3}, {0, 1, 3}};
    if (c2 == 0)
        return {{0, 1, 2}, {0, 1, 3}};
    return {{0, 2, 3}, {0, 1, 3}};
}
