#include<iostream>
using namespace std;
int main(){
  int n;
  int ball[100][10],count=0;
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin >> ball[i][j];
    }
    for(int j=0;j<6;j++){
      if(ball[i][j] > ball[i][j+2] || ball[i][j+1] > ball[i][j+3]){
	cout << "NO" << endl;
	  count++;
	  break;
      }
    }
    if(count == 0){
      cout << "YES" << endl;
    }
  }
}