#![allow(non_snake_case, unused_imports)] use itertools::Itertools; use proconio::{input, marker::Chars, marker::Usize1}; use std::cmp::{Reverse, max, min}; use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque}; #[allow(unused_macros)] macro_rules! d { ( $( $x:expr ),* $(,)? ) => { eprintln!( concat!( $( stringify!($x), "={:?} " ),* ), $( $x ),* ); }; } #[allow(dead_code)] fn yn(b: bool) -> &'static str { if b { "Yes" } else { "No" } } fn f(xs: &[i64]) -> bool { let [a, b, c, d, e] = xs else { unreachable!(); }; a == c && b == d && d == e && a != b } fn main() { input! { T: usize, } for _ in 0..T { input! { N: usize, A: [i64; 5 * N], } let ans = A .chunks(5) .all(|a| f(a)); println!("{}", yn(ans)); } }