def solve(x, y): assert x != y l = min(len(x), len(y)) if x[:l] < y[:l]: return 'Y' elif x[:l] > y[:l]: return 'X' if x * 100 < y * 100: return 'Y' else: return 'X' for _ in range(int(input())): x = input() y = input() print(solve(x, y))