#include <iostream>
using namespace std;

bool f(void){
	int a=0, b=0, e;
	for (int i=0; i<10; i++){
		cin>>e;
		if (e>a) a=e;
		else if (e>b) b=e;
		else return false;
	}
	return true;
}

int main(void){

	int n;

	cin>>n;
	while (n--){
		if (f()) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}