fn solve() -> bool { let xyd = input(); let mut xyd = xyd.split(' '); let x1: u64 = xyd.next().unwrap().parse().unwrap(); let y1: u64 = xyd.next().unwrap().parse().unwrap(); let d1: &str = xyd.next().unwrap(); let xyd = input(); let mut xyd = xyd.split(' '); let x2: u64 = xyd.next().unwrap().parse().unwrap(); let y2: u64 = xyd.next().unwrap().parse().unwrap(); let d2: &str = xyd.next().unwrap(); match (d1, d2) { (dt1, dt2) if dt1 == dt2 => false, ("L", "R") => y1 == y2 && x1 > x2, ("R", "L") => y1 == y2 && x1 < x2, ("U", "D") => x1 == x2 && x1 < x2, ("D", "U") => x1 == x2 && x1 > x2, _ => { let dx = if x1 < x2 { x2 - x1 }else { x1 - x2 }; let dy = if y1 < y2 { y2 - y1 }else { y1 - y2 }; dx == dy }, } } fn main() { let t: usize = input().parse().unwrap(); for _ in 0..t { println!("{}", if solve() { "Yes" } else { "No" }); } } fn input() -> String { let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).unwrap(); return buffer.trim().to_string(); }