// Template was built with the help of generative AI #include #include using namespace std; using namespace __gnu_pbds; // --------------------------- DATA STRUCTURES --------------------------- template using indexed_set = tree< T, null_type, less, rb_tree_tag, tree_order_statistics_node_update >; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; // --------------------------- MACROS & CONSTANTS --------------------------- #define ll long long #define endl "\n" #define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); const ll MOD = 1e9 + 7; const ll INF = 1e18; const double PI = 3.141592653589; // --------------------------- OBSERVATIONS --------------------------- /* OB1: 10101010 01010101 010 101 1 01 0 10 1010101 -1 1010100 /2 101010 /2 10101 -1 10100 /2 1010 /2 101 -1 if msb same, that means same amount of operations x = 0, y = 0 x = 2, y = 1 5 times lets do both ways 64, 6 69, 192 18 digits pqrstu pqrstu abcdea bcde 10 6 abcdefghij pqrstu */ /* OB2: */ /* Final: */ // --------------------------- MAIN --------------------------- int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); ll t; cin >> t; while (t--) { string s1, s2; cin >> s1 >> s2; string s3 = s1 + s2; string s4 = s2 + s1; if (s3 > s4) { cout << 'X' << endl; } else if (s4 > s3) { cout << 'Y' << endl; } else { if (s1.length() > s2.length()) { cout << 'X' << endl; } else { cout << 'Y' << endl; } } } return 0; }