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(|j| j%n+1).collect::>(); if a == x { println!("Yes"); return; } for i in 0..n { let mut x = (0..2*n).map(|j| j%n+1).collect::>(); x[i..=n+i].reverse(); if x == a { 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(); } }