import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val numCases = nextInt() case@ for (_i in 0 until numCases) { val n = nextInt() val a = Array(2 * n) { nextInt() } val x = Array(2 * n) { if (it < n) it + 1 else it - n + 1 } if (a.contentEquals(x)) { println("Yes") continue@case } for (i in 0 until n) { val b = Array(2 * n) { 0 } for (j in 0 until 2 * n) { if (j <= i || j >= i + n) { b[j] = x[j] } else { b[j] = x[2 * i + n - j] } } if (a.contentEquals(b)) { println("Yes") continue@case } } println("No") } } fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion