for _ in range(int(input())): x = input(); y = input() m = len(x); n = len(y) for i in range(max(m, n)): if x[i%m] > y[i%n]: print("X"); break if x[i%m] < y[i%n]: print("Y"); break else: print("X" if m > n else "Y")