#include "triangles.h"

#include <bits/stdc++.h>

using namespace std;

bool onOneSide(int a, int b, int p1, int p2) {
    int res = compare({Triangle(a, p1, p2), Triangle(b, p1, p2)}, {Triangle(a, b, p1), Triangle(a, b, p2)});
    return res != 0;
}

bool isInside(int a, int b, int c, int p) {
    int res = compare({Triangle(a, b, p), Triangle(a, c, p), Triangle(b, c, p)}, {Triangle(a, b, c)});
    return res == 0;
}

std::vector<std::vector<int>> solve(int n) {
    assert(n == 1);
    vector<int> p(n);

    iota(p.begin(), p.end(), 0);
    do {
        if(isInside(p[0], p[1], p[2], p[3])) {
            return {{p[0], p[1], p[3]}, {p[1], p[2], p[3]}, {p[2], p[0], p[3]}};
        }
    } while(next_permutation(p.begin(), p.end()));

    iota(p.begin(), p.end(), 0);
    do {
        if(onOneSide(p[0], p[1], p[2], p[3])) {
            return {{p[0], p[1], p[2]}, {p[0], p[1], p[3]}};
        }
    } while(next_permutation(p.begin(), p.end()));
}
