fn solve() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let x = (0..2*n).map(|i| i%n + 1).collect::>(); if a == x { println!("Yes"); return;; } for i in 0..n { let mut temp = x.clone(); temp[i..=i+n].reverse(); if a == temp { println!("Yes"); return; } } println!("No"); } fn main() { let mut t = String::new(); std::io::stdin().read_line(&mut t).ok(); let t: usize = t.trim().parse().unwrap(); for _ in 0..t { solve(); } }