Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	for i := 0; i < n; i++ {
		a := -1
		b := -1
		ans := true
		// それぞれの筒の一番上にあるたまの数字に着目すればよい
		for j := 0; j < 10; j++ {
			x := nextInt()
			if x > a {
				a = x
			} else if x > b {
				b = x
			} else {
				ans = false
			}
		}
		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include <iostream>
#include <array>
#include <vector>

using namespace std;



int main()
{
        int num = 0, tmp_right, tmp_left, ispush = 0, i, j;
        std::array< int, 10 > ar;
        std::vector< int > right, left;
        cin >> num;

        for ( j = 0 ; j < num ; j = j + 1 )
        {
                for ( i = 0 ; i < 10 ; i = i + 1 )
                {
                        cin >> ar[i];
                        ispush = 0;
                        if ( right.size() == 0 )
                        {
                                ispush = 1;
                                right.push_back( ar[i] );
                        }
                        else if ( right.size() != 0 )
                        {
                                tmp_right = right.back();
                                if ( tmp_right < ar[i] )
                                {
                                        right.push_back( ar[i] );
                                        ispush = 1;
                                }
                        }

                        if ( ispush == 0 )
                        {
                                if ( left.size() == 0 )
                                {
                                        ispush = 1;
                                        left.push_back( ar[i] );
                                }
                                else if ( left.size() != 0 )
                                {
                                        tmp_left = left.back();
                                        if ( tmp_left < ar[i] )
                                        {
                                                ispush = 1;
                                                left.push_back( ar[i] );
                                        }
                                }
                        }

                        if ( ispush == 0 )
                        {
                                cout << "NO" << endl;
                                break;
                        }
                        else
                        {
                                ispush = 0;
                        }
//                      cout << i << endl;
                        if ( i == 9 )
                        {
                                cout << "YES" << endl;
                        }


                }
                right.clear();
                left.clear();

        }


        return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	vector<int> a1, a2;
	int t, i;
	ios::sync_with_stdio(false);
	cin >> t;
	while(t --)
	{
		int x;
		bool flg = 1;
		a1.push_back(0);
		a2.push_back(0);
		for(i = 0; i < 10; i ++)
		{
			cin >> x;
			if(a1.back() < x)	a1.push_back(x);
			else if(a2.back() < x) 	a2.push_back(x);
			else
			{
				flg = 0;
				break;
			}
		}
		for( i ++; i < 10; i ++)	cin >> x;
		flg ? cout << "YES" << endl : cout << "NO" << endl;
		a1.clear();
		a2.clear();
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;

int main(){
	int n, m[12];
	bool flag;
	vector<int> b,c;

	cin >> n;

	for(int i=0 ; i<n ; i++){
		for(int j=0 ; j<10 ; j++){
			cin >> m[j];
		}

		flag = true;
		for(int j=0 ; j<10 ; j++){
			if(b.empty() && c.empty()){
				b.push_back( m[j] );
			}else if(b[ b.size()-1 ]<m[j]){
				b.push_back( m[j] );
			}else if( c.empty() ){
				c.push_back( m[j] );
			}else if(c[c.size()-1]<m[j]){
				c.push_back( m[j] );
			}else{
				flag = false;
				break;
			}
		}
		if(flag){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int a[11],b[11],flag;
void dfs(int step){
	if(flag){
		return ;
	}
	if(step==10){
		int s1=0,s2=0,inf=0;
		for(int i=0;i<10;i++){
			if(b[i]==1){
				if(a[i]>s1){
					s1=a[i];
				}
				else{
					inf=1;break;
				}
			}
			else{
				if(a[i]>s2){
					s2=a[i];
				}
				else{
					inf=1;break;
				}
			}
		}
		if(!inf){
			flag=1;
		}
		return ;
	}
	b[step]=0;
	dfs(step+1);
	b[step]=1;
	dfs(step+1);
	return ;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		flag=0;
		for(int i=0;i<10;i++){
			scanf("%d",&a[i]);
		}
		dfs(0);
		if(flag){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

C++: #include<iostream>
#include<queue>
using namespace std;

int main()
{
	int ball = 10;	//ボールの数
	int n,k;	//n:セットの数 k:メモ
	cin >> n;	
	queue<int> a;	//開口部Ａ
	int b = 0 , c = 0;	//筒Ｂ、筒Ｃ
	queue<bool> flag;	//成功したセット


	for (int i=0; i < n; i++){		//1セットのループ
		for (int j=0; j < ball; j++){
			cin >> k;
			a.push( k );
		}
		b = a.front();
		a.pop();	//最初の一個
		
		for (int j=0; j < (ball-1); j++){		//ボールのループ
			if (a.front() > b && a.front() > c){	//どっちも乗せられる
				if (a.front() - b > a.front() - c){
					c = a.front();
				}else{
					b = a.front();	//差の小さい方に乗せる
				}
			}else if(a.front() > b){
				b = a.front();
			
			}else if(a.front() > c){
				c = a.front();
			
			}else {	
				flag.push(false);
				while(1){
					if(!a.empty()){
						a.pop();
					}else
						break;
				}
				break;	//終了
			}
			a.pop();	//乗せた
			if (a.empty()){		//最後まで乗せた
				flag.push(true);
				while(1){
					if(!a.empty()){
						a.pop();
					}else
						break;
				}
			}
		}
	}

	for (int i = 0; i < n; i++){
		if (flag.front()){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
		flag.pop();
	}

	return 0;

}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    int p; cin>>p;
    rep(hogehoge,p){
        vi v(10,0);rep(i,10)cin>>v[i];
        vb flag(11,false);flag[v[0]]=true;
        pii num=pii(v[0],INF);
        rep(i,10){
            if(i==0)continue;
            if(num.first<v[i]){flag[v[i]]=true; num.first=v[i];}
        }
        rep(i,10){
            if(flag[v[i]])continue;
            else if(num.second==INF){num.second=v[i];flag[v[i]]=true;}
            if(num.second<v[i]){flag[v[i]]=true; num.second=v[i];}
        }
        bool judge=true;
        rep(i,10)if(!flag[i+1])judge=false;
        if(judge)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}