#pragma GCC optimize("Ofast") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast(chrono::duration_cast(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin >> q; while(q--){ string s,t; cin >> s >> t; { auto r = s, rr = t; sort(r.begin(), r.end()); sort(rr.begin(), rr.end()); if(r[0] == r.back() and r.back() == rr[0] and rr[0] == rr.back()){ if(r < rr){ cout << "Y" << "\n"; } else{ cout << "X" << "\n"; } continue; } } bool f = false; auto ti = time(); for(int i=0,j=0;;){ if(s[i] > t[j]){ cout << "X" << "\n"; f = true; break; } else if(s[i] < t[j]){ cout << "Y" << "\n"; f = true; break; } if(time()-ti > 0.08) break; i++; j++; if(i == s.size()) i = 0; if(j == t.size()) j = 0; } if(f) continue; if(s < t){ cout << "Y" << "\n"; } else{ cout << "X" << "\n"; } } }