#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ff first
#define ss second
#define tobit(n) bitset<(int)30>(n)
typedef unsigned long long ull;
#define all(v) (v).begin(), (v).end()
#pragma GCC optimize("Ofast","inline","-ffast-math")
#define rtt(v) rotate(vec.begin(), vec.begin() + k, vec.end()); //move k elements back
vector<int> dx = {1, -1, 0, 0, 1, 1, -1, -1}, dy = {0, 0, 1, -1, 1, -1, 1, -1};
vector<pair<int, int>> DX = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
const vector<pair<int, int>> ANS = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const int MOD = 1e9 + 7, N = (int)1e6, inf = numeric_limits<int>::max();
template <typename T>
extern int press(string p);
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void IO(string str_ = ""){
    if((int)str_.size()){
        freopen((str_ + ".in").c_str(), "r", stdin);
        freopen((str_ + ".out").c_str(), "w", stdout);
    }
}
//signed main(){ // clock_t the_time = clock(); double t_;
//	IO(""); int n, result = 0; cin >> n;
//    vector<int > a(n), b(n), c(n);
//    for(auto &to : a) cin >> to;
//    for(auto &to : b) cin >> to;
//    for (int i = 0; i < n; i++) c[i] = a[i] - b[i];
//    sort(c.begin(), c.end());
//    auto UPPB = [&](long long x) -> int {
//        int l = 0, r = n;
//        while(l < r){
//            int m = (l + r) / 2;
//            if(c[m] <= x) l = m + 1;
//            else r = m;
//        } return l;
//    }; for(int i = 0; i < n; i++){
//        result += n - UPPB(-c[i]);
//        if(UPPB(-c[i]) <= i) result--;
//    } cout << result / 2;
//    // t_ = double(clock() - the_time) / CLOCKS_PER_SEC; cout << fixed << setprecision(16)<<  t_ << " sec.";
//}
string guess_sequence(int N) {
    string s; vector<char> res_;
    if(press("AB") > 0){
        if(press("A") > 0) s = "A";
        else s = "B";
    } else {
        if(press("X") > 0) s = "X";
        else s = "Y";
    } if(N == 1){ return s; }
    for(char c : {'A', 'B', 'X', 'Y'}) {
        if(c != s[0]) res_.emplace_back(c);
    } for(int i = 1; i < N - 1; i++){
        string str = s + res_[0] + s + res_[1] + res_[0] + s + res_[1] + res_[1] + s + res_[2];
        int res = press(str);
        if(res == i) s += res_[2];
        else if(res == i + 1) s += res_[0];
        else s += res_[1];
    } if(press(s + res_[0]) == N) s += res_[0];
    else if(press(s + res_[1]) == N) s += res_[1];
    else s += res_[2];
    return s;
}
const int fastIO = [](){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    return 0;
}();
/*
    Открыть терминал: F5
    Закрыть терминал: F6
    Спрятать/показать терминал: F7
    Скомпилировать и запустить: F9
    Только запустить: F12
*/
Compilation message (stderr)
combo.cpp:20:26: error: 'T' was not declared in this scope
   20 | using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
      |                          ^
combo.cpp:20:45: error: 'T' was not declared in this scope
   20 | using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
      |                                             ^
combo.cpp:20:46: error: template argument 1 is invalid
   20 | using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
      |                                              ^
combo.cpp:20:95: error: template argument 1 is invalid
   20 | using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
      |                                                                                               ^
combo.cpp:20:95: error: template argument 3 is invalid
combo.cpp: In function 'std::string guess_sequence(long long int)':
combo.cpp:49:13: error: no matching function for call to 'press(const char [3])'
   49 |     if(press("AB") > 0){
      |        ~~~~~^~~~~~
combo.cpp:19:12: note: candidate: 'template<class T> long long int press(std::string)'
   19 | extern int press(string p);
      |            ^~~~~
combo.cpp:19:12: note:   template argument deduction/substitution failed:
combo.cpp:49:13: note:   couldn't deduce template parameter 'T'
   49 |     if(press("AB") > 0){
      |        ~~~~~^~~~~~
combo.cpp:50:17: error: no matching function for call to 'press(const char [2])'
   50 |         if(press("A") > 0) s = "A";
      |            ~~~~~^~~~~
combo.cpp:19:12: note: candidate: 'template<class T> long long int press(std::string)'
   19 | extern int press(string p);
      |            ^~~~~
combo.cpp:19:12: note:   template argument deduction/substitution failed:
combo.cpp:50:17: note:   couldn't deduce template parameter 'T'
   50 |         if(press("A") > 0) s = "A";
      |            ~~~~~^~~~~
combo.cpp:53:17: error: no matching function for call to 'press(const char [2])'
   53 |         if(press("X") > 0) s = "X";
      |            ~~~~~^~~~~
combo.cpp:19:12: note: candidate: 'template<class T> long long int press(std::string)'
   19 | extern int press(string p);
      |            ^~~~~
combo.cpp:19:12: note:   template argument deduction/substitution failed:
combo.cpp:53:17: note:   couldn't deduce template parameter 'T'
   53 |         if(press("X") > 0) s = "X";
      |            ~~~~~^~~~~
combo.cpp:60:24: error: no matching function for call to 'press(std::string&)'
   60 |         int res = press(str);
      |                   ~~~~~^~~~~
combo.cpp:19:12: note: candidate: 'template<class T> long long int press(std::string)'
   19 | extern int press(string p);
      |            ^~~~~
combo.cpp:19:12: note:   template argument deduction/substitution failed:
combo.cpp:60:24: note:   couldn't deduce template parameter 'T'
   60 |         int res = press(str);
      |                   ~~~~~^~~~~
combo.cpp:64:15: error: no matching function for call to 'press(std::__cxx11::basic_string<char>)'
   64 |     } if(press(s + res_[0]) == N) s += res_[0];
      |          ~~~~~^~~~~~~~~~~~~
combo.cpp:19:12: note: candidate: 'template<class T> long long int press(std::string)'
   19 | extern int press(string p);
      |            ^~~~~
combo.cpp:19:12: note:   template argument deduction/substitution failed:
combo.cpp:64:15: note:   couldn't deduce template parameter 'T'
   64 |     } if(press(s + res_[0]) == N) s += res_[0];
      |          ~~~~~^~~~~~~~~~~~~
combo.cpp:65:18: error: no matching function for call to 'press(std::__cxx11::basic_string<char>)'
   65 |     else if(press(s + res_[1]) == N) s += res_[1];
      |             ~~~~~^~~~~~~~~~~~~
combo.cpp:19:12: note: candidate: 'template<class T> long long int press(std::string)'
   19 | extern int press(string p);
      |            ^~~~~
combo.cpp:19:12: note:   template argument deduction/substitution failed:
combo.cpp:65:18: note:   couldn't deduce template parameter 'T'
   65 |     else if(press(s + res_[1]) == N) s += res_[1];
      |             ~~~~~^~~~~~~~~~~~~
combo.cpp: In function 'void IO(std::string)':
combo.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen((str_ + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combo.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen((str_ + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~