#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
string S = "";
string p = "";
string c1, c2, c3;
if (press("AB")) {
if (press("A")) {
S = "A";
c1 = 'B', c2 = 'X', c3 = 'Y';
} else {
S = "B";
c1 = 'A', c2 = 'X', c3 = 'Y';
}
} else {
if (press("X")) {
S = "X";
c1 = 'B', c2 = 'A', c3 = 'Y';
} else {
S = "Y";
c1 = 'B', c2 = 'X', c3 = 'A';
}
}
while (S.size() < N) {
int c = S.size();
if (c == N - 1) {
if (press(S + c1) > c) {
S += c1;
break;
} else if (press(S + c2) > c) {
S += c2;
break;
} else {
S += c3;
break;
}
}
p = S + c1 + c1 + S + c1 + c2 + S + c2 + c2;
int ret = press(p);
// cout<<p<<endl;
if (ret == c) {
S += c3;
continue;
} else if (ret == c + 1) {
int plus = press(S + c2 + c3);
if (plus == c) {
S += "" + c1 + c3;
} else if (plus == c + 1) {
S += "" + c2 + c1;
} else if (plus == c + 2) {
S += "" + c2 + c3;
}
continue;
} else if (ret == c + 2) {
int plus = press(S + c1 + c2);
if (plus == c) {
S += "" + c2 + c2;
} else if (plus == c + 1) {
S += "" + c1 + c1;
} else if (plus == c + 2) {
S += "" + c1 + c2;
}
continue;
}
}
return S;
}