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<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;

	rep(i,0,n){
		int x=0,y=0;
		bool f = 1;
		rep(j,0,10){
			
			int b;
			if(!f){
				cin >> b;
				continue;
			}

			cin >> b;
			if( b - x > 0 && b - x <= b - y )
				x = b;
			else if( b - y > 0 )
				y = b;
			else{
				f = 0;
			}
			//cout << x << " " << y << endl;
		}

		if(f)
			YES;
		else
			NO;
	}
	
	ret 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int n;
int a[1000][11];
int stock[2][11];
int usea[11];

int dfs(int num, int r_num, int l_num) {
	int res = 0;

	if (usea[num] > stock[0][r_num]) {
		if (num == 9)
			return 1;
		stock[0][r_num + 1] = num;
		res = dfs(num + 1, r_num + 1, l_num);
		stock[0][r_num + 1] = -1;
		return res;
	}
	else if (usea[num] > stock[1][l_num]) {
		if (num == 9)
			return 1;
		stock[1][l_num + 1] = num;
		res = dfs(num + 1, r_num, l_num + 1);
		stock[1][l_num + 1] = -1;
		return res;
	}
	else {
		return 0;
	}
}


int main()
{
	cin >> n;

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			usea[j] = a[i][j];
		}
		stock[0][0] = -1;
		stock[0][1] = usea[0];
		stock[1][0] = -1;
		if (dfs(0, 1, 0)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		stock[0][0] = -1;
		stock[0][1] = -1;
		stock[1][0] = -1;
	}

	return 0;
}

C++: //
//  0033.cpp
//  
//
//  Created by Yoshida Satoshi on 2017/11/16.
//
//

#include <iostream>
using namespace std;

void tsumu(int l,int r,int* in,int j,bool *ans){
    if(j==9){
        *ans=true;
        return;
    }
    if(in[j]>l) tsumu(in[j],r,in,j+1,ans);
    if(in[j]>r) tsumu(l,in[j],in,j+1,ans);
    
    return;
}

int main(){
    int N;
    int in[10];
    int l;
    int r;
    bool ans=false;
    
    cin>>N;
    for(int i=0;i<N;i++){
        l=r=0;
        for(int j=0;j<10;j++){
            cin>>in[j];
        }
        if(tsumu(l,r,in,0,&ans)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
 
int b[10];
  
bool dfs(int i,int j,int k){
  if(k==10)
    return true;
  if(i<b[k]){
    if(dfs(b[k],j,k+1))return true; 
  }
  if(j<b[k]){
    if(dfs(i,b[k],k+1))return true;
  }
  return false;
}
 
int main(){
  int a;
  cin >> a;
  while(a>0){
    for(int i=0;i<10;i++){
      cin >> b[i];
    }
    int p=dfs(0,0,0);
    if(p!=0)
      cout << "YES" << endl;
    else
      cout << "NO" <<endl;
    a--;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll; 
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;


ll n, a[100], C = 0, B = 0;

int main(){
	cin >> n;
	REP(i, n){
		C = 0, B = 0;
		REP(j, 10)cin >> a[j];
		REP(j, 10){
			if (a[j] > B){
				B = a[j];
			}
			else if (a[j] > C){
				C = a[j];
			}
			else{
				cout << "NO\n";
				break;
			}
			if (j == 9){
				cout << "YES\n";
			}
		}
	}
}

C++: #include <stdio.h>

#include <stack>

int main(void){
    using namespace std;
    stack<int> a,b;
    int n,j,i,ball,flag;
    scanf("%d",&n);
    for(j=0; j<n; j++){
        flag=0;
        for(i=0; i<10; i++){
            scanf("%d",&ball);
            if(a.empty()){
                a.push(ball);
            }else if(a.top() < ball){
                a.push(ball);
            }else if(b.empty()){
                b.push(ball);
            }else if(a.top() < ball){
                b.push(ball);
            }else{
                flag=1;
            }
        }
        if(flag==0){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a[10];
	cin>>n;
	for(int i=0;i<n;i++){
		bool t=true;
		for(int j=0;j<10;j++)
			cin>>a[i];
		for(int j=0;j<8;j++){
			if(a[j]>a[j+2]&&a[j+1]>a[j+2])
				t=false;
		}
		if(t==true)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}

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

int ma[11];
int a[11];int b[11];

bool ch;

int dx[]={1,0,0,-1};
int dy[]={0,-1,1,0};

void dfs(int deep,int aa,int bb)
{
    if(ch)return ;
    if(deep==10)
    {
        ch=true;
        return ;
    }


    if(ma[deep]>a[aa-1])
    {
        a[aa]=ma[deep];
        dfs(deep+1,aa+1,bb);
    }

    if(ch==false&&ma[deep]>b[bb-1])
    {
        b[bb]=ma[deep];
        dfs(deep+1,aa,bb+1);
    }

}


int main()
{
    int f;
    scanf("%d",&f);
    while(f--)
    {
        ch=false;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for(int i=0;i<10;i++)
            scanf("%d",&ma[i]);
        dfs(0,1,1);
        if(ch)
            printf("YES\n");
        else
            printf("NO\n");
    }


}

C++: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i,n)   for (int i = 0; i < (n); ++i)
#define SORT(a)    sort((a).begin(), (a).end());
#define UNIQ(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define FIND(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define REVERSE(a) reverse((a).begin(), (a).end());

using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MOD = 1000000007; // 10^9 + 7

int a[10];

bool dfs(int i, int b, int c) {
  if (i == 10) return true;

  if (a[i] > b && dfs(i + 1, a[i], c)) return true;
  if (a[i] > c && dfs(i + 1, b, a[i])) return true;
  return false;
}

bool solve() {
  return dfs(0, -1, -1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  REP(i, n) {
    REP(j, 10) cin >> a[j];
    cout << (solve() ? "YES" : "NO") << endl;
  }
}