#include using namespace std; #ifdef LOCAL #include #else #define debug(...) 42 #endif int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { string x, y; cin >> x >> y; int n = (int) min(x.size(), y.size()); int ans = -1; for (int i = 0; i < n; i++) { if (x[i] < y[i]) { ans = 0; } else if (x[i] > y[i]) { ans = 1; } } if (ans == -1) { n = 2 * max((int) x.size(), (int) y.size()); for (int i = 0; i < n; i++) { int px = i % (int) x.size(); int py = i % (int) y.size(); if (x[px] < y[py]) { ans = 0; } else if (x[px] > y[py]) { ans = 1; } } } if (ans == -1) { ans = (x.size() < y.size() ? 0 : 1); } cout << (ans == 0 ? "Y" : "X") << '\n'; } return 0; }