def f(): N = int(input()) A = list(map(int,input().split())) pre = -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 pre==-1 and A[i]!=x: start = A[i-1] pre = A[i] elif pre>0: if start==A[i]:pre=-1;continue if pre!=A[i]+1:return 'No' pre = A[i] return 'Yes' T = int(input()) for i in range(T):print(f())