#include <iostream>
#include <queue>
using namespace std;

int n;
queue<int> q;

int main(){
	cin >> n;
	int tmp;
	for(int I=0;I<n;I++){
		q = queue<int>();
		int a = 0;
		for(int i = 0; i < 10; i++){
			cin >> tmp;
			if(a<tmp){
				a = tmp;
			}
			else{
				q.push(tmp);
			}
		}
		a = 0;
		bool f = false;
		while(q.size() > 0){
			tmp = q.front(); q.pop();
			if(a < tmp){
				a = tmp;
			}
			else{
				f = true;
				break;
			}
		}
		if(f){
			cout << "NO" << endl;
		}
		else{
			cout << "YES" << endl;
		}
	}

	return 0;
}