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 <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define repp(i, n) rep(i, n)
#define reppp(i, n) repp(i, n)
#define rrepp(i, n) rrep(i, n)
#define repss(i, n) reps(i, n)
#define repcc(i, n) repc(i, n)
#define repii(i, a, b) repi(i, a, b)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  while (n--) {
    vi32 v(10); cin >> v;
    bool ans = false;
    rep(i, bit(10)) {
      stack<int> a, b;
      bool f = true;
      rep(j, 10) {
        stack<int> *x;
        if (i & bit(j)) x = &a; else x = &b;
        if (x->size() == 0) x->push(v[j]);
        else {
          if (x->top() > v[j]) f = false;
          else x->push(v[j]);
        }
      }
      if (f) {
        ans = true;
        break;
      }
    }
    if (ans) cout << "YES" << '\n';
    else cout << "NO" << '\n';
  }
}

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,r,n) for(int i=r;i<(int)n;i++)
using namespace std;
int in() {int x; cin >> x; return x;}

int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		bool ans = true;
		int r = -1, l = -2;

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

			if (r>x)
			{
				ans = false;
				break;
			}
			if(r>l)swap(r,l);

			if(l<x)l=x;
			else r=x;

			if(r>l)swap(r,l);
		}
		if(ans)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;


	}
	return 0;

}

C++: #include<cstdio>
#include<string>
#include<vector>
#include<fstream>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<cwctype>
#include<algorithm>
#include<math.h>

using namespace std;


int data[10];

bool searchB (int a){
	vector<int >sea;

	for(int i=0;i<10;i++){
		if(a>>i & 1)sea.push_back(data[i]);
	}
	if(sea.size()>1){
	for(int i=0;i<sea.size()-1;i++){
		if(sea[i]>sea[i+1])return false;
	}
	}
	return true;
}

int main(){

	int n=0;
	cin>>n;

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

	for(int j=0;j<10;j++){
		cin>>data[j];
	}
	bool suc=false;
	for(int i=0;i<1024;i++){
		if(searchB(i) && searchB(~i)){
			cout<<"YES"<<endl;
			suc=true;
			break;
		}
	}
	if(!suc)cout<<"NO"<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(void)
{
    int bo[11],n,B[11],C[11],b1=0,c1=0,A=0,k=0,l=1;
    cin>>n;
    for(int i=0;i<n;i++){
            C[0]=11;k=0;l=0;B[0]=0;b1=0;c1=0;
        for(int j=0;j<10;j++){
            cin>>bo[j];
        }
        for(int j=1;;j++){
              //  cout<<bo[j]<<" ";
            if(j==1)B[0]=bo[0];
        if(B[l]<bo[j]){
            b1=1;
            B[l+1]=bo[l];
            l++;
           // cout<<"1\n";
        }else if(C[0]==11){
            C[0]=bo[j];
            k++;
           // cout<<"2\n";
        }else if(C[k-1]<bo[j]){
            c1=1;
            C[k+1]=bo[j];
           // cout<<"3\n";
        }else if(B[l]<bo[j+1]){
            C[k+1]=bo[j];
            k++;
           // cout<<"5\n";
        }else{
            B[l+1]=bo[j];
            l++;
            //cout<<"4\n";
        }
        if(j==9||(b1==1&&c1==1))break;
    }
    if(b1==1&&c1==1)cout<<"YES\n";
    else cout<<"NO\n";
    for(int j=0;j<10;j++){
        B[j]=0;C[j]=0;
    }

}
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<cstdio> 
using namespace std;
int A[10],B[11],C[11];
bool dfs(int a,int b,int c){
	if(a==10){
		return true;
	}
	bool flag=false;
	if(A[a]>B[b-1]){
		B[b]=A[a];
		flag |=dfs(a+1,b+1,c);
	}	
	if(A[a]>C[c-1]){
		C[c]=A[a];
		flag |=dfs(a+1,b,c+1);
	}
	return flag;
}
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		for(int i=0;i<10;i++){
			scanf("%d",&A[i]);
		}
		if(dfs(0,1,1)){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
const int N = 10;
int main(){
    int n,i,ans,a,b,c;;
    cin >> n;
    while(n--) {
    	ans=1;
    	b=c=-1;
        for(i=0;i<10;i++){
        	cin>>a;
        	if(a>b)
        		b=a;
        	else if(a>c)
        		c=a;
        	else
        		ans=0;
		}
		if(ans) puts("YES");
    	else puts("NO");
    }
}

C++: #include <cstdio>
#include <algorithm>
#define HEIGHT 10

using namespace std;

int a[HEIGHT];

void solve(){
	bool f=true;
	int right,left;
	right = left = 0;
	for(int i=0;i<HEIGHT;i++){
		if(right<a[i] && left<a[i]){
			if(right<left){
				left = a[i];
			} else {
				right = a[i];
			}
		} else if(right<a[i]){
			right = a[i];
		} else if(left<a[i]){
			left = a[i];
		} else {
			f = false;
			break;
		}
	}
	if(f) printf("YES");
	else printf("NO");
}
			
int main(){
	
	int lp;
	scanf("%d",&lp);
	
	for(int i=0;i<lp;i++){
		for(int j=0;j<HEIGHT;j++){
			scanf(" %d",&a[j]);
		}
		solve();	
	}
	return 0;
}

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

int main(){
  int N,t,B,C;
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    B = C = 0;
    int j;
    for( j = 0; j < 10; j++){
      cin >> t;
      if(B >= t && C >= t) break;
      else if(B < t && C < t){
	if(B < C) B = t;
	else B = t;
      }
      else if(B < t) B = t;
      else if(C < t) C = t;
      //      cout << B << " ";
    }
    if(j == 10) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}