use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let t: usize = itr.next().unwrap().parse().unwrap(); for _ in 0..t { let n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec = (0..n * 2) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let mut ok = true; for i in 0..n { ok &= a[i] == i + 1; } if !ok { println!("No"); } else { let mut ok2 = false; for i in (n + 1..n * 2).rev() { let mut b = Vec::new(); for j in (n..i).rev() { b.push(a[j]); } for j in i..n * 2 { b.push(a[j]); } let mut tmp = true; for j in 0..n { tmp &= b[j] == j + 1; } ok2 |= tmp; } if ok2 { println!("Yes"); } else { println!("No"); } } } }