use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let l: Vec<_> = s.lines().skip(1).collect(); l.chunks(3).for_each(|l| { let a: Vec = l[0].split(' ').flat_map(str::parse).collect(); let c: Vec = l[1].split(' ').flat_map(str::parse).collect(); let i = match l[2] { "WA" => 1, "TLE" => 2, "MLE" => 3, "OLE" => 4, _ => 5, }; println!( "{}", if a[i] == 0 && c.iter().enumerate().all(|(j, &x)| i == j || x == 0) { "Yes" } else { "No" } ) }) }