#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
void init(int T) {}
vector<int> order(int cnt[]) {
vector <int> res;
for (int i = 0;i < 6;i++) {
for (int j = 1;j <= 6;j++) {
if (cnt[j] == i) {
res.push_back(j);
break;
}
}
}
// for (int i = 1;i <= 6;i++) {
// cout << cnt[i] << " ";
// }
// cout << endl;
// for (auto x : res) {
// cout << x << " ";
// }
// cout << endl;
return res;
}
//1 2 4 5 3 6
// void print(int cnt[]) {
// for (int i = 1;i <= 6;i++) {
// cout << cnt[i] << " ";
// }
// cout << endl;
// }
void orderCoins() {
int W[] = {1, 2, 3, 4, 5, 6};
int x1 = getLightest(1, 2, 3);
int x3 = getHeaviest(1, 2, 3);
int x2 = 6 - x1 - x3;
int y1 = getLightest(4, 5, 6);
int y3 = getHeaviest(4, 5, 6);
int y2 = 15 - y1 - y3;
int cnt[7] = {0};
cnt[x3] += 2;
cnt[x2]++;
cnt[y3] += 2;
cnt[y2]++;
// print(cnt);
bool pos = false; //true = x1 > y1, false = x1 < y1
int truemid = getMedian(x1, y1, x2);
if (truemid == y1) {
cnt[y1]++;
cnt[x2]++;
cnt[x3]++;
}
else if (truemid == x1){
pos = true;
cnt[x1]++;
cnt[x2]++;
cnt[x3]++;
}
else {
cnt[y1] += 2;
pos = true;
int temp = getHeaviest(x2, y1, x3);
if (temp == y1) {
cnt[y1]++;
cnt[y2] += 3;
cnt[y3] += 3;
vector <int> res = order(cnt);
for (int i = 0;i < 6;i++) {
W[i] = res[i];
}
answer(W);
return;
}
else {
cnt[x3]++;
}
}
// print(cnt);
int z2 = getNextLightest(x1, x2, x3, y2);
if (z2 == x2) {
cnt[x2]++;
cnt[x3]++;
cnt[y2]++;
}
if (z2 == x3) {
cnt[x3]++;
cnt[y2] += 2;
}
bool biggest = false;
if (z2 == x1) {
if (getLightest(x1, y2, y3) == y2) {
cnt[x1]++;
cnt[x2]++;
cnt[x3]++;
}
else {
cnt[y2] += 3;
biggest = true;
}
}
// print(cnt);
int z3 = getNextLightest(x1, x2, x3, y3);
// cout << z3 << endl;
if (z3 == x2) {
cnt[x2]++;
cnt[x3]++;
cnt[y3]++;
}
if (z3 == x3) {
cnt[x3]++;
cnt[y3] += 2;
}
if (z3 == x1) {
if (getLightest(x1, x2, y3) == y3) {
cnt[x1]++;
cnt[x2]++;
cnt[x3]++;
}
else {
cnt[y3] += 3;
}
}
vector <int> res = order(cnt);
for (int i = 0;i < 6;i++) {
W[i] = res[i];
}
answer(W);
return;
}