from math import gcd for _ in range(int(input())): S = list(input().rstrip()) T = list(input().rstrip()) n, m = len(S), len(T) ST = S + T TS = T + S if ST > TS: print('X') elif ST < TS: print('Y') else: if n > m: print('X') else: print('Y')