#include <iostream>

using namespace std;

int N;
int tama[11];

bool dfs(int n){
	if(tama[n+2]<=tama[n])	return false;
	if(n==6||n==7)	return true;
	dfs(n+2);
}

int main(){
	cin >> N;
	while(N--){
		for(int i=0;i<10;i++)
			cin >> tama[i];
		if(dfs(0)&&dfs(1))	cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}