#include "triangles.h"
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
using namespace std;

std::vector<std::vector<int>> solve(int n) {
    assert(n == 4);
    // Example of compare:
    // Пример использования функции compare:
    auto A = Triangle(1, 2, 3); // 0
    auto B = Triangle(0, 2, 3); // 1
    auto C = Triangle(0, 1, 3); // 2
    auto D = Triangle(0, 1, 2); // 3
    int c0 = compare({A, C}, {B, D});
    int c1 = compare({A, B}, {C, D});
    vector<vector<int>> ans;
    if (c0 == 0 || c1 == 0) {
        if (c0 == 0) return {{0, 1, 3}, {2, 3, 1}}; // 0 - 2
        return {{0, 2, 3}, {1, 2, 3}}; // 0 - 1
    }
    else {
        assert(c0 && c1);
        c0 = c0 == -1; // right win in c0
        c1 = (c1 == -1);
        // cout << "CCC: " << c0 << " " << c1 << endl;
        int m = -1;
        if (c0 && c1) m = 3; // D
        else if (!c0 && c1) m = 2; // C
        else if (c0 && !c1) m = 1; // B
        else if (!c0 && !c1) m = 0; // A
        vector <int> x = {0, 1, 2, 3};
        x.erase(find(x.begin(), x.end(), m));
        for (int i = 0; i < 3; ++i) for (int j = i + 1; j < 3; ++j) ans.push_back({m, x[i], x[j]});
        return ans;
    }
    return ans;
}
