T = int(input()) ans = ["X", "Y"] for _ in range(T): X = list(input()) Y = list(input()) if X + Y < Y + X: print("Y") elif X + Y > Y + X: print("X") else: if len(X) < len(Y): print("Y") else: print("X")