t = int(input()) for _ in range(t): x = input() y = input() if x+y > y+x: print('X') elif x+y < y+x: print('Y') else: if len(x) > len(y): print('X') else: print('Y')