#include <iostream>
using namespace std;

int main(){
	int a[10],n,i;
	bool can;
	while(cin >> n){
		for(i=0;i<n;i++){
			for(int j = 0;j<10;j++){
				cin >> a[j];
			}
			for(int j = 1;j<=7;j+=2){
				if(a[j] < a[j+2] && a[j-1] < a[j+1]) can = true;
				else {
					can = false;
					break;
				}
			}
			if(can == true) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
	return 0;
}