import sys input = sys.stdin.readline T=int(input()) for t in range(T): x = input().strip() y = input().strip() xy = x+y yx = y+x if xy > yx: print("X") elif xy < yx: print("Y") else: print("X" if len(x)>len(y) else "Y")