T = int(input()) X = [] Y = [] for _ in range(T): X.append(input()) Y.append(input()) for i in range(T): x = X[i] y = Y[i] lenx = len(x) leny = len(y) if lenx>leny: v = -(-lenx//leny) y = y*v y = y[:len(x)] if x>=y: print('X') else: print('Y') else: v = -(-leny//lenx) x = x*v x = x[:len(y)] if y>=x: print('Y') else: print('X')