T = gets.to_s.to_i T.times do n = gets.to_s.to_i a = gets.to_s.split.map { |s| s.to_i } x = (0 ... n * 2).map { |i| i % n + 1 } if a == x puts "Yes" next end if (0 ... n).any? do |i| y = x.dup y[i, n + 1] = x[i, n + 1].reverse a == y end puts "Yes" next end puts "No" end