T = int(input())
for i in range(T):
    N = int(input())
    ls = list(map(int,input().split()))
    stls = [i for i in range(1,N+1)]+[i for i in range(1,N+1)]
    if ls == stls:
        print('Yes')
        continue
    for j in range(N):
        vls = stls[:j+1]+stls[j+1:j+N][::-1]+stls[j+N:]
        if ls == vls:
            print('Yes')
            break
    else:
        print('No')