use std::fmt::format; fn solve() -> char { let mut x = String::new(); std::io::stdin().read_line(&mut x).ok(); let x = x.trim(); let mut y = String::new(); std::io::stdin().read_line(&mut y).ok(); let y = y.trim(); if x.len() == y.len() { if x > y { return 'X'; } else { return 'Y'; } } let x = x.chars().collect::>(); let y = y.chars().collect::>(); let xlen = x.len(); let ylen = y.len(); if xlen > ylen { for i in 0..xlen*2 { if x[i%xlen] != y[i%ylen] { if x[i%xlen] > y[i%ylen] { return 'X'; } else { return 'Y'; } } } return 'X'; } for i in 0..ylen*2 { if x[i%xlen] != y[i%ylen] { if x[i%xlen] > y[i%ylen] { return 'X'; } else { return 'Y'; } } } return 'Y'; } fn main() { let mut t = String::new(); std::io::stdin().read_line(&mut t).ok(); let t: usize = t.trim().parse().unwrap(); let mut result = Vec::with_capacity(t); for _ in 0..t { result.push(solve()); } for &c in result.iter() { println!("{}", c); } }