#include <bits/stdc++.h>
#include "triangles.h"
using namespace std;
#define int long long
//using namespace __gnu_pbds;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

std::vector<std::vector<int>> solve(int n) {
    vector<vector<int>> t = {{0, 1, 2}, {0, 1, 3}, {0, 2, 3}, {1, 2, 3}};

    vector<int> cnt(4);
    

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            if (i != j) {
                if (compare(vector<Triangle>{Triangle(t[i][0], t[i][1], t[i][2])}, vector<Triangle>{Triangle(t[j][0], t[j][1], t[j][2])}) >= 0) {
                    cnt[i] += 1;
                }
            }
        }
    }


    int best = 0;
    for (int i = 0; i < 4; i++) {
        if (cnt[best] < cnt[i]) {
            best = i;
        }
    }

    int x = 0;

    for (int i = 0; i < 4; i++)  {
        bool legit = true;
        for (auto e : t[best]) {
            if (e == i) legit = false;
        }
        if (legit) x = i;
    }

    int i = best;

    if (compare(vector<Triangle>{Triangle(t[i][0], t[i][1], t[i][2])}, vector<Triangle>{Triangle(t[i][0], t[i][1], x), Triangle(t[i][0], t[i][2], x), Triangle(t[i][2], t[i][1], x)}) == 0)  {
        return vector<Triangle>{Triangle(t[i][0], t[i][1], x), Triangle(t[i][0], t[i][2], x), Triangle(t[i][2], t[i][1], x)};
    }

    if (compare(vector<Triangle>{Triangle(t[i][0], t[i][1], t[i][2]), Triangle(t[i][0], t[i][1], x)}, vector<Triangle>{Triangle(t[i][0], t[i][2], x), Triangle(t[i][2], t[i][1], x)}) == 0)  {
        return vector<Triangle>{Triangle(t[i][0], t[i][1], t[i][2]), Triangle(t[i][0], t[i][1], x)};
    }

    if (compare(vector<Triangle>{Triangle(t[i][0], t[i][1], t[i][2]), Triangle(t[i][0], t[i][2], x)}, vector<Triangle>{Triangle(t[i][0], t[i][1], x), Triangle(t[i][2], t[i][1], x)}) == 0)  {
        return vector<Triangle>{Triangle(t[i][0], t[i][1], t[i][2]), Triangle(t[i][0], t[i][2], x)};
    }

    if (compare(vector<Triangle>{Triangle(t[i][0], t[i][1], t[i][2]), Triangle(t[i][2], t[i][1], x)}, vector<Triangle>{Triangle(t[i][0], t[i][2], x), Triangle(t[i][0], t[i][1], x)}) == 0)  {
        return vector<Triangle>{Triangle(t[i][0], t[i][1], t[i][2]), Triangle(t[i][2], t[i][1], x)};
    }

    return vector<Triangle>{Triangle(52, 179, 180)};
}

