T = gets.to_i T.times do n = gets.to_i a = gets.split.map(&:to_i) x = [*1..n] * 2 if a[0] != 1 || a[-1] != n || a.sort != x.sort puts 'No' else ok = true 1.upto(2 * n - 2) do |i| y = a[i - 1] x = a[i] z = a[i + 1] next if y == x - 1 || y == (x % n) + 1 next if z == x - 1 || z == (x % n) + 1 ok = false end if ok puts 'Yes' else puts 'No' end end end