#include<iostream>

using namespace std;

int main()
{
	int N;
	
	cin >> N;
	
	for(int n = 0;n < N;n++)
	{
		int tubeB = 0, tubeC = 0;
		bool ans = true;
		
		for(int i = 0;i < 10;i++)
		{
			int ball;
			cin >> ball;
			
			if(tubeB < ball) tubeB = ball;
			else if(tubeC < ball) tubeC = ball;
			else ans = false;
		}
		
		if(ans) cout << "YES\n";
		else cout << "NO\n";
	}
	
	return 0;
}