#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int ball[10];
  int i,j;
  for(j=0;j<n;j++){
    for(i=0;i<10;i++) scanf("%d",&ball[i]);
    int a=0,b=0;
    for(i=0;i<10;i++){
      if(a<ball[i]) a = ball[i];
      else if(b<ball[i]) b = ball[i];
      else{
	printf("NO\n");
	break;
      }
      if(i==9) printf("YES\n");
    }
  }
  return 0;
}