#include <bits/stdc++.h>
using namespace std;

int main(){
	int N;
	cin>>N; 
	while(N-->0){
		int frist=0,last=0,a;
		string s = "YES";
		for(int i=0;i<10;i++){
			cin>>a;
			if(a>last){
				last = a;
			}else if(a>frist){
				frist = a;
			}else {
				frist = -1;
				s = "NO";
			}
		}
		cout<<s<<endl;
	}
	return 0;
}
