for _ in range(int(input())): x = list(input()) y = list(input()) xx = x + x yy = y + y n = min(len(x),len(y))*2 cnt = 0 for i in range(n): cnt += xx[i] == yy[i] if cnt != n: if xx > yy: print("X") elif xx < yy: print("Y") else: if len(x) > len(y): print("X") else: print("Y")