#include "triangles.h"
#include <algorithm>

using namespace std;

std::vector<std::vector<int>> solve(int n) {
  vector <int> p = {0, 1, 2, 3};
  bool f = false;
  do {
    if (compare({Triangle(p[0], p[1], p[2]), Triangle(p[0], p[2], p[3])},
                {Triangle(p[0], p[1], p[3]), Triangle(p[1], p[3], p[2])}) == 0) {
      f = true;
      break;
    }
    next_permutation(p.begin(), p.end());
  } while (p != vector<int>{0, 1, 2, 3});
  if (!f) {
    for (int i1 = 0; i1 < 4; i1++) {
      for (int j1 = i1 + 1; j1 < 4; j1++) {
        for (int k1 = j1 + 1; k1 < 4; k1++) {
          bool f = true;
          for (int i2 = 0; i2 < 4; i2++) {
            for (int j2 = i2 + 1; j2 < 4; j2++) {
              for (int k2 = j2 + 1; k2 < 4; k2++) {
                f = f && compare({Triangle(i1, j1, k1)}, {Triangle(i2, j2, k2)}) >= 0;
              }
            }
          }
          if (f) {
            return {{i1, j1, i1 ^ j1 ^ k1}, {i1, k1, i1 ^ j1 ^ k1}, {k1, j1, i1 ^ j1 ^ k1}};
          }
        }
      }
    }
  }
  return {{p[0], p[1], p[2]}, {p[0], p[2], p[3]}};
}
