def f(): N = int(input()) A = list(map(int,input().split())) p = -1 start = -1 if N==1 and A[0]==1 and A[1]==1:return 'Yes' if A[0]!=1:return 'No' for i in range(1,2*N): if A[i]==A[i-1]:return 'No' x = (i+1)%N if (i+1)%N!=0 else N if p==-1 and A[i]!=x: start = A[i-1] p = 1 elif p>0: if start==A[i] and p==N-1:p=-1;continue if A[i-1]!=A[i]+1:return 'No' p +=1 return 'Yes' T = int(input()) for i in range(T):print(f())