#include<cstdio>
using namespace std;
int main(){
	int t;
	scanf("%d", &t);
	while(t--){        
		int a, b = -1, c = -1;
		bool flag = true;
		for(int i = 1; i <= 10; i++){
			scanf("%d", &a);
			if(flag){
				if(a > b)   //????¬?????????????b??¶?????¢??? 
					b = a;
				else if(a > c)
					c = a;
				else
					flag = false;
			}
		}
		printf("%s\n", flag? "YES" :"NO");
	}
	return 0;
}