def solve(): n = int(input()) A = list(map(int, input().split())) B = [] ok = True for i in range(n): B.append(i + 1) if A[i] != A[i + n]: ok = False if ok: print("Yes") return l = r = -1 for i in range(n): B.append(i + 1) if A[i] == A[i + n]: l = i r = i + n if l == -1: print("No") return A[l:r+1] = A[l:r+1][::-1] if A == B: print("Yes") else: print("No") for _ in range(int(input())): solve()