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 { 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()-1).collect(); let xorg = (0..2).flat_map(|_| (0..n).collect::>()).collect::>(); if xorg == a { println!("Yes"); continue; } let mut flg = false; for i in 0..n { let mut x = xorg.clone().to_owned(); x[i..=i+n].reverse(); if x == a { flg = true; break; } } if flg { println!("Yes"); } else { println!("No"); } } }