#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,l[10],a,b;
  cin>>n;
  while(n){
    a=b=0;
    cin>>l[0]>>l[1]>>l[2]>>l[3]>>l[4]>>l[5]>>l[6]>>l[7]>>l[8]>>l[9];
    for(int i=0;i<10;i++){
      if(!(i%2)){
	if(l[i]>a)a=l[i];
	else
	  break;
      }
      else{
	if(l[i]>b)b=l[i];
        else
	  break;
      }
    }
    (a==l[8]&&b==l[9])?cout<<"YES":cout<<"NO";
    cout<<endl;
    n--;
  }
  return 0;
}