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<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
int a,b,temp,n;
int main()
{
    int n;
    cin>>n;
    while(n--){
        int flag=1;
        a=0,b=0;
        queue<int>que;
        while(que.size())que.pop();
        for(int i=0;i<10;i++){
            cin>>temp;
            que.push(temp);
        }
        while(que.size()){
            temp=que.front();
            que.pop();
            if(temp<=a&&temp<=b){
                cout<<"NO\n";
                flag=0;
                break;
            }
            else if(temp<=a&&temp>b)b=temp;
            else if(temp<=b&&temp>a)a=temp;
            else {
                if(a>=b)a=temp;
                else b=temp;
            }
        }
        if(flag)cout<<"YES\n";
    }

    return 0;
}

C++: #include <iostream>

using namespace std;


int main(){

	int n, A, B, C;
	bool ans;

	cin >> n;

	while (n--){
		ans = true;
		B = 0;
		C = 0;

		for (int i = 0; i < 10; i++){
			cin >> A;

			if (A > B){
				B = A;
			}
			else if(A > C){
				C = A;
			}
			else{
				ans = false;
			}
		}

		cout << (ans ? "YES" : "NO") << endl;

	}


	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int b[10];
  int t;
  cin>>t;
  while(t--){
    for(int i=0;i<10;i++)
      cin>>b[i];
    int now=b[0];
    b[0]=0;
    for(int i=1;i<10;i++)
      if(b[i]>now){
	now=b[i];
	b[i]=0;
      }
    for(int i=0;i<10;i++)
      if(b[i]>0){
	now=i;
	break;
      }
    bool flag=true;
    for(int i=now;i<10;i++)
      if(b[i]>0&&b[i]<b[now])
	flag=false;
    if(flag)cout<<"YES\n";
    else cout<<"NO\n";
  }
}

C++: #include <stdio.h>

int main(void)
{
	int tubeM[10];
	int tube1[10], tube2[9];
	int i, j, k;
	int n;
	int ans;
	
	scanf("%d", &n);
	
	while(n){
		for (i = 0; i < 9; i++){
			tube2[i] = 0;
		}
		
		for (i = 0; i < 10; i++){
			scanf("%d", &tubeM[i]);
		}
		
		tube1[0] = tubeM[0];
		for (i = 1, j = 0, k = 0; i < 10; i++){
			if (tubeM[i] > tube1[j]){
				j++;
			}
			else {
				tube2[k] = tubeM[i];
				k++;
			}
		}
		
		ans = 0;
		for (i = 1; tube2[i] != 0; i++){
			if (tube2[i - 1] > tube2[i]){
				ans = 1;
				break;
			}
		}
		
		if (ans == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		
		n--;
	}
	
	return (0);
}

C++: #include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int main(){
  int n;
  cin>>n;
  while(n--){
    int left=-1,right=-1;
    bool flag = true;
    REP(i,10){
      int x;
      cin>>x;
      if(x>right){
        right = x;
      }else if(x>left){
        left = x;
      }else{
        flag = false;
      }
    }
    if(flag){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		vector<int> pile1;
		vector<int> pile2;
		pile2.push_back(0);
		int num[10];
		cin>>num[0]>>num[1]>>num[2]>>num[3]>>num[4]>>num[5]>>num[6]>>num[7]>>num[8]>>num[9];
		pile1.push_back(num[0]);
		for(int j=1;j<=9;j++){
			if(pile1[pile1.size()-1]<num[j]) pile1.push_back(num[j]);
			else if(pile2[pile2.size()-1]<num[j]) pile2.push_back(num[j]);
			else{
				cout<<"NO"<<endl;
				break;
			}
			if(j==9) cout<<"YES"<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int B,C; int N; int A[10];
bool dfs(int i){
  if(i==10) return true;
  if(A[i]>max(B,C)){
    if(B>C){B=A[i];}else{C=A[i];} dfs(i+1);
  }else if(A[i]<max(B,C)&&A[i]>min(B,C)){
    if(B>C){C=A[i];}else{B=A[i];} dfs(i+1);
  }else{
    return false;
  }
 }
void solve(){
  B=0; C=0;
  for(int i=0; i<10; i++){
      cin>>A[i];
    }
  if(dfs(0)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
    }
  }
int main() {
  cin>>N;
  for(int i=0; i<N; i++){
  solve();
  }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void){
	int n,a,b,c;
	bool f;
	cin>>n;
	for(int i=0;i<n;i++){
		f=true;b=0;c=0;
		for(int j=0;j<10;j++){
			cin>>a;
			if(b>a&&c>a){
				f=false;
				break;
			}else if(b<a && c<a){
				if(b>=c)b=a;
				else c=a;
			}else if(b<a){
				b=a;
			}else if(c<a){
				c=a;
			}
		}
		if(f)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

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

int n;
int ball[10];
int r, l;
int now;

bool dfs(int r, int l, int now);

int main(){

	cin >> n;

	for(int i=0; i<n; i++){
		r = 0;
		l = 0;
		now = 0;

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

		if(dfs(0, 0, 0)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

bool dfs(int right, int left, int now){
	if(now == 10) return true;
	if(right < ball[now]) return dfs(ball[now], left, now+1);
	if(left < ball[now]) return dfs(right, ball[now], now+1);
	return false;
}

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];
stack<int> vi1, vi2;

int main(){
	cin >> n;
	REP(i, n){
		REP(j, 10){
			cin >> a[j];
		}
		REP(j, 10){
			if (vi1.empty()){
				vi1.push(a[j]);
				continue;
			}
			if (vi2.empty()){
				if (vi1.top() > a[j]){
					vi2.push(vi1.top());
					vi1.pop();
					vi1.push(a[j]);
				}
				else{
					vi2.push(a[j]);
				}
				continue;
			}
			if (vi2.top() < a[j]){
				vi2.push(a[j]);
			}
			else{
				if (vi1.top() < a[j]){
					vi1.push(a[j]);
				}
				else{
					cout << "NO" << endl;
					break;
				}
			}
			if (j == 10 - 1){
				cout << "YES" << endl;
			}
		}
		while (!vi1.empty()){
			vi1.pop();
		}
		while (!vi2.empty()){
			vi2.pop();
		}
	}
}