fn main() {
    let t = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<usize>().unwrap()
    };

    for _ in 0..t {
        println!("{}", if solve() { "Yes" } else { "No" });
    }
}

fn solve() -> bool {
    let (x1, y1, d1) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse::<i64>().unwrap(),
            iter.next().unwrap().parse::<i64>().unwrap(),
            iter.next().unwrap().parse::<char>().unwrap(),
        )
    };
    let (x2, y2, d2) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse::<i64>().unwrap(),
            iter.next().unwrap().parse::<i64>().unwrap(),
            iter.next().unwrap().parse::<char>().unwrap(),
        )
    };

    if d1 == d2 {
        return false;
    }

    let (vx1, vy1) = velocity(d1);
    let (vx2, vy2) = velocity(d2);

    (x1 == x2 && vx1 == vx2 || vx1 != vx2 && (x2 - x1) / (vx1 - vx2) > 0)
        && (y1 == y2 && vy1 == vy2 || vy1 != vy2 && (y2 - y1) / (vy1 - vy2) > 0)
}

fn velocity(d: char) -> (i64, i64) {
    match d {
        'R' => (1, 0),
        'L' => (-1, 0),
        'U' => (0, 1),
        'D' => (0, -1),
        _ => panic!(),
    }
}