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; let mut ok1 = true; let mut ok2 = true; let mut b = Vec::new(); let mut c = Vec::new(); b.push(1); for i in (2..=n).rev() { b.push(i); } for i in 1..=n { b.push(i); c.push(i); } for i in (1..n).rev() { c.push(i); } c.push(n); for i in 0..n * 2 { ok &= a[i] == i % n + 1; ok1 &= a[i] == b[i]; ok2 &= a[i] == c[i]; } if ok || ok1 || ok2 { println!("Yes"); } else { println!("No"); } } }