#include <iostream>
using namespace std;
int main (){
	int N;
	int L = 0;
	int R = 0;
	cin >> N;
	int T[N][10];
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < 10; ++j)
		{
			cin >> T[i][j];			
		}
	}
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < 10; ++j)
		{
			if(L < T[i][j]){
				L = T[i][j];
				if(j == 9){
					cout << "YES\n";
				}
			}else if(R < T[i][j]){
				R = T[i][j];
				if(j == 9){
					cout << "YES\n";
				}
			}else{
				cout << "NO\n";
				break;
			}
		}
	}
	return 0;
}