def f(): N = int(input()) A = list(map(int,input().split())) ws,wg = -1,-1 for i in range(2*N): x = (i+1)%N if (i+1)%N!=0 else N if ws==-1 and A[i]!=x: ws = i if ws!=-1 and A[i]==x: wg = i if ws!=-1 and wg!=-1: tmp = A[ws:wg+1][::-1] k = 0 for j in range(ws,wg): y = (j+1)%N if (j+1)%N!=0 else N if not tmp[k]!=y:return 'No' k+=1 return 'Yes' T = int(input()) for i in range(T):print(f())