#include<cstdio>

int main(){
	int n, b, c, t;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		b = c = 0;
		for(int j = 0; j < 10; j++){
			scanf("%d", &t);
			if(b < t){
				b = t;
			}else{
				if(c < t){
					c = t;
					if(b < c){
						t = b;
						b = c;
						c = t;
					}
				}else{
					t = 0;
					j += 10;
				}
			}
		}

		if(t){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}