a=int(input()) for i in range(a): b=int(input()) c=list(map(int,input().split())) n=0 for j in range(b-1): if n%2==0 and c[j]c[j+1]: n+=1 if n==4: break if n==3: print('Yes') else: print('No')