#include "triangles.h"
#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;

std::vector<std::vector<int>> solve(int n) {
    std::vector<Triangle> left = {Triangle(0, 1, 2), Triangle(0, 1, 3)};
    std::vector<Triangle> right = {Triangle(0, 1, 2), Triangle(0, 2, 3)};
    int compare_result = compare(left, right);
    bool are_equl = true;
    if (compare_result == 1) {
        left = right;
    }
    if (compare_result) {
        are_equl = false;
    }
    right = {Triangle(0, 1, 2), Triangle(1, 2, 3)};
    compare_result = compare(left, right);
    if (compare_result == 1) {
        left = right;
    }
    if (compare_result) {
        are_equl = false;
    }
    std::vector<Triangle> new_left = {Triangle(0, 1, 3), Triangle(0, 1, 2)};
    std::vector<Triangle> new_right = {Triangle(0, 1, 3), Triangle(0, 2, 3)};
    compare_result = compare(new_left, new_right);
    if (compare_result == 1) {
        new_left = new_right;
    }
    if (compare_result) {
        are_equl = false;
    }
    new_right = {Triangle(0, 1, 3), Triangle(1, 2, 3)};
    compare_result = compare(new_left, new_right);
    if (compare_result == 1) {
        new_left = new_right;
    }
    if (compare_result) {
        are_equl = false;
    }
    compare_result = compare(left, new_left);
    if (compare_result == 1) {
        left = new_left;
    }
    if (compare_result) {
        are_equl = false;
    }
    vector<Triangle> t1 = {Triangle(0, 1, 2)};
    vector<Triangle> t2 = {Triangle(0, 2, 3)};
    vector<Triangle> t3 = {Triangle(1, 2, 3)};
    vector<Triangle> t4 = {Triangle(0, 1, 3)};
    if (compare(t1, t2) == -1) {
        t1 = t2;
    }
    if (compare(t1, t3) == -1) {
        t1 = t3;
    }
    if (compare(t1, t4) == -1) {
        t1 = t4;
    }
    if (!are_equl) {
        std::vector<std::vector<int>> ans(1, std::vector<int>(3));
        ans[0][0] = t1[0].i;
        ans[0][1] = t1[0].j;
        ans[0][2] = t1[0].k;
        return ans;
    } else {
        std::vector<std::vector<int>> ans(2, std::vector<int>(3));
        ans[0][0] = left[0].i;
        ans[0][1] = left[0].j;
        ans[0][2] = left[0].k;
        ans[1][0] = left[1].i;
        ans[1][1] = left[1].j;
        ans[1][2] = left[1].k;
        return ans;
    }
}