#include "triangles.h"
#include<unordered_set>
#include<random>
using namespace std;


vector<vector<int>> solve(int n) {
    mt19937 rnd(3);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        a[i] = i;
    }

    for (int &center : a) {
        vector<int> last;
        for (auto &e : a) {
            if (center != e) {
                last.push_back(e);
            }
        }

        vector<Triangle> common(1);
        common[0] = {last[0], last[1], last[2]};

        vector<Triangle> inside;
        for (int i = 0; i < 3; ++i) {
            for (int j = i+1; j < 3; ++j) {
                Triangle curr = {last[i], last[j], center};
                inside.push_back(curr);
            }
        }

        int res = compare(common, inside);
        if (res == 0) {
            vector<vector<int>> ans(3, vector<int>(3));
            for (int i = 0; i < 3; ++i) {
                ans[i] = {inside[i].i, inside[i].j, inside[i].k};
            }
            return ans;
        }
    }

    vector<vector<int>> final1 = {{0, 1, 2}, {1, 3, 0}};
    vector<vector<int>> final2 = {{0, 1, 2}, {3, 3, 0}};
    return (rnd() % 2 ? final1 : final2);
}
