#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
	int N,pre,current,second_pre;
	bool NO_FLG;

	scanf("%d",&N);
	for(int i=0;i<N;i++){
		pre = -1;
		second_pre = -1;
		NO_FLG = false;
		for(int k = 0; k < 10; k++){
			scanf("%d",&current);
			if(k == 0){
				pre = current;
			}else{
				if(pre > current){
					if(second_pre == -1){
						second_pre = pre;
					}else{
						if(second_pre > pre){
							printf("NO\n");
							NO_FLG = true;
							break;
						}else{
							second_pre = pre;
						}
					}
				}
				pre = current;
			}
		}
		if(!NO_FLG)printf("YES\n");

	}
	return 0;
}