use proconio::input; use std::collections::HashSet; fn solve() { input! { n: usize, xyc: [(i32, i32, char); 2 * n], } let mut cntx = 0; let mut stx = HashSet::new(); let mut cnty = 0; let mut sty = HashSet::new(); for (x, y, c) in xyc { match c { 'x' => { cntx += 1; if stx.contains(&y) { stx.remove(&y); } else { stx.insert(y); } }, 'y' => { cnty += 1; if sty.contains(&x) { sty.remove(&x); } else { sty.insert(x); } }, _ => unreachable!(), } } let ans = if stx.len() < sty.len() { sty.len() - stx.len() <= cntx - stx.len() } else { stx.len() - sty.len() <= cnty - sty.len() }; println!("{}", if ans {"Yes"} else {"No"}); } fn main() { input! { t: usize, } for _ in 0..t { solve(); } }