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 mut 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"); continue; } let idx = (0..n).filter(|&i| a[i] == i+1).max().unwrap_or(n); if idx == n { println!("No"); continue; } a[idx..=idx+n].reverse(); if a == x { println!("Yes"); } else { println!("No"); } } }