#include <iostream>
using namespace std;

int main(void){
	int c;
	cin >> c;
	for(int j = 0; j < c-1; j++){
		int data[10];
		for(int i = 0; i < 10; i++){
			cin >> data[i];
		}

		int B, C = 0;
		B = data[0];
		bool flag = 0;

		for(int i = 1; i < 10; i++){
			if(B+1 != data[i]){
				if(C == 0){
					C = data[i];
				}else if(C+1 != data[i]){
					cout << "NO" << endl;
					break;
				}else{
					C = data[i];
				}
			}else{
				B = data[i];
			}
			if(i == 9){cout << "YES" << endl;}
		}
	}

}