#include <cstdio>
using namespace std;

int ball[10];
bool dfs(int point, int right, int left){
	if(point == 10) return true;
	if(right < ball[point]) return dfs(point + 1, ball[point], left);
	if(left < ball[point]) return dfs(point + 1, right, ball[point]);
	return false;
}
int main(){
	int N;
	scanf("%d", &N);
	while(N){
		for(int i = 0; i < 10; i++){
			scanf("%d", &ball[i]);
		}
		if(dfs(0, 0, 0)) printf("YES\n");
		else printf("NO\n");
		N--;
	}
}