#include "triangles.h"

#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> solve(int n) {
    //assert(n == 4);
    vector<vector<int>> ans;
    for (int mask = 0; mask < (1 << 4); mask++) {
        if (__builtin_popcount(mask) != 3) {
            continue;
        }
        vector<int> v;
        int d;
        if ((mask >> 0) & 1) v.push_back(0);
        else d = 0;
        if ((mask >> 1) & 1) v.push_back(1);
        else d = 1;
        if ((mask >> 2) & 1) v.push_back(2);
        else d = 2;
        if ((mask >> 3) & 1) v.push_back(3);
        else d = 3;
        int a = v[0];
        int b = v[1];
        int c = v[2];
        vector<Triangle> left = {{a,b,d}, {b,c,d}, {a,c,d}};
        vector<Triangle> right = {{a,b,c}};
        int res = compare(left, right);
        if (res == 0) {
            ans = {{a,b,d}, {b,c,d}, {a,c,d}};
        }
    }
    if (ans.empty()) {
        vector<int> p(4);
        iota(p.begin(), p.end(), 0ll);
        do {
            vector<Triangle> left = {{p[0],p[1],p[2]}, {p[2], p[0], p[3]}};
            vector<Triangle> right = {{p[0], p[1], p[3]}, {p[1], p[3], p[2]}};
            if (compare(left, right) == 0) {
                ans = {{p[0], p[1], p[2], p[3]}};
            }
        } while (next_permutation(p.begin(), p.end()));
    }
    return ans;
}
