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

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);
    if (compare_result == 1) {
        left = right;
    }
    right = {Triangle(0, 1, 2), Triangle(1, 2, 3)};
    compare_result = compare(left, right);
    if (compare_result == 1) {
        left = right;
    }
    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;
    }
    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;
    }
    compare_result = compare(left, new_left);
    if (compare_result == -1) {
        left = new_left;
    }
    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;
}

