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 } if (0 ... n * 2).all? { |i| a[i] == i % n + 1 } puts "Yes" next end i = a.rindex(1) xs = a[0 .. i] ys = a[i + 1 ..] if xs.reverse == xs and ys.reverse == ys puts "Yes" next end puts "No" end