def paln(i,j,A): for k in range(j-i+1): if A[i+k]!=A[j-k]: return False return True def check(N,A): for i in range(N): if A[i]!=i+1 or A[i]!=A[i+N]: return False return True T = int(input()) for _ in range(T): N = int(input()) A = list(map(int,input().split())) if check(N,A): print("Yes") else: B = {i:[] for i in range(1,N+1)} for i in range(2*N): B[A[i]].append(i) B = list(B.values()) C = [0]*len(B) k = 0 for i,j in B: if paln(i,j,A): C[k] = 1 k += 1 if C.count(0)!=1: print("No") else: k = C.index(0) i,j = B[k] A[i:j+1] = A[i:j+1][::-1] if check(N,A): print("Yes") else: print("No")