fn solve() -> String { 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 target = (0..2*n).map(|i| i % n + 1).collect::>(); if a == target { return "Yes".to_string(); } for i in 0..n { let mut x = target.clone().to_owned(); x[i..=i+n].reverse(); if x == a { return "Yes".to_string(); } } "No".to_string() } fn main() { let mut t = String::new(); std::io::stdin().read_line(&mut t).ok(); let t: usize = t.trim().parse().unwrap(); let mut result = Vec::with_capacity(t); for _ in 0..t { result.push(solve()); } for v in result.iter() { println!("{}", v); } }