#include <stdio.h>


void solve(){
	int tan;
	int sho;

	int flg = 0;
	for (int i=0; i<10; ++i){
		int tama;
		scanf("%d", &tama);
		if (!i) {
			tan = tama;
			continue;
		}
		if (i==1) {
			sho = tama;
			continue;
		}
		if (i%2 == 0){
			if (tama < tan) flg = 1;
			tan = tama;
		}else {
			if (tama < sho) flg = 1;
			sho = tama;
		}
	}
	printf("%s\n", flg?"NO":"YES");
}

int main (){
	int t;
	scanf("%d", &t);
	while (t --){
		solve();
	}
	return 0;
}