import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); PrintWriter pw = new PrintWriter(System.out); for (int z = 0; z < t; z++) { String x = br.readLine(); String y = br.readLine(); if (x.length() == y.length()) { if (x.compareTo(y) > 0) { pw.println("X"); } else { pw.println("Y"); } } else { StringBuilder sbx = new StringBuilder(x); StringBuilder sby = new StringBuilder(y); while (sbx.length() < sby.length()) { sbx.append(x); } while (sbx.length() > sby.length()) { sby.append(y); } String x2 = sbx.toString(); String y2 = sby.substring(0, x2.length()); int cmp = x2.compareTo(y2); if (cmp == 0) { if (x.length() > y.length()) { pw.println("X"); } else { pw.println("Y"); } } else if (cmp > 0) { pw.println("X"); } else { pw.println("Y"); } } } pw.flush(); br.close(); } }