#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	for( int i = 0; i < n; ++i ) {
		vector<int> a( 10 );
		for( auto& v: a ) { cin >> v; }

		bool result = true;
		int x = 0;
		int y = 0;

		for( int j = 0; j < 10; ++j ) {
			if( a[j] > x ) {
				x = a[j];
			}
			else if( a[j] > y ) {
				y = a[j];
			}
			else {
				result = false;
				break;
			}
		}

		cout << (result ? "YES" : "NO") << '\n';
	}
}

