import sys input = sys.stdin.readline T=int(input()) for tests in range(T): x=input().strip() y=input().strip() for i in range(max(len(x)*2,len(y)*2)): if x[i%len(x)]>y[i%len(y)]: print("X") break elif x[i%len(x)]len(y): print("X") else: print("Y")