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>
using namespace std;
int main(){
  int t;
  cin >> t;
  int n[10];
  int b[10]={0};
  int c[10]={0};
  int bcount=0,ccount=0,h=0;
  for(int i=0;i<t;i++){
    for(int j=0;j<10;j++) cin >> n[j];
    for(int j=0;j<10;j++){
      if(b[0]==0) b[bcount] = n[j];
      else if(b[bcount]>c[ccount]&&b[bcount]<n[j]){
	bcount++;
	b[bcount] = n[j];
      }
      else if(c[ccount]>b[bcount]&&c[ccount]<n[j]){
	if(c[ccount]!=0) ccount++;
	c[ccount] = n[j];
      }
      else if(b[bcount]>c[ccount]&&b[bcount]>n[j]&&c[ccount]<n[j]){
	if(c[ccount]!=0) ccount++;
	c[ccount] = n[j];
      }
      else if(c[ccount]>b[bcount]&&c[ccount]>n[j]&&b[bcount]<n[j]){
	bcount++;
	b[bcount] = n[j];
      }
      else if(b[bcount]>n[j]&&c[ccount]>n[j]){
	cout << "NO" << endl;
	h = 1;
	break;
      }
    }
    if(h==0) cout << "YES" << endl;
    for(int i=0;i<10;i++){
      b[i] = 0;
      c[i] = 0;
    }
      bcount = 0;
      ccount = 0;
      h = 0;
  }
  return 0;
}

C++: #include<stack>	//スタック
#include<iostream>

using namespace std;

int main(void){
	int n,i,data[10],ans=1;
	stack<int> right;
	stack<int> left;

	cin>>n;
	while(n>0){
		n--;
		cin>>data[0]>>data[1]>>data[2]>>data[3]>>data[4]>>data[5]>>data[6]>>data[7]>>data[8]>>data[9];
		right.push(data[0]);
		for(i=1;i<10;i++){
			if(right.top()<data[i])
				right.push(data[i]);
			else{
				if(left.empty())
					left.push(data[i]);
				else{
					if(left.top()<data[i])
						left.push(data[i]);
					else
						ans=0;
				}
			}
		}
		if(ans==0) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
		while(!left.empty())
			left.pop();
		while(!right.empty())
			right.pop();
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
const int N = 20;

int ball[N];

bool dfs(int n, int l, int r)
{
    if (n == 10)    return true;
    if (ball[n] < l && ball[n] < r) return false;
    if (ball[n] > l)
    {
        if(dfs(n+1, ball[n], r))   return true;
    }
    if (ball[n] > r)
    {
        if (dfs(n+1, l, ball[n]))    return true;
    }
    return false;
}

int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        for (int i = 0; i < 10; ++i)
            cin >> ball[i];
        bool flag = dfs(0 , 0, 0);
        if (flag)   cout << "YES" << endl;
        else    cout << "NO" << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define sor(v) sort(v.begin(),v.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))

const int INF=1000000000;
const int dre_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dre_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	cin>>n;
	
	rep(i,n){
		int a[12];
		rep(j,10)cin>>a[j];
		
		int b=0,c=0;
		bool ret=true;
		rep(j,10){
			if(a[j]>b)b=a[j];
			else if(a[j]>c)c=a[j];
			else ret=false;
		}
		
		if(ret)cout<<"YES\n";
		else cout<<"NO\n";
	}
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
	int n;
	cin >> n;
	rep(i, n) {
		stack<int> l, r;
		rep(j, 10) {
			int x;
			cin >> x;
			if (l.size() == 0) {
				l.push(x);
				continue;
			}
			if (r.size() == 0) {
				if (l.top() < x) {
					l.push(x);
					continue;
				}
				r.push(x);
				continue;
			}
			if (l.top() < r.top()) {
				if (r.top() < x) {
					r.push(x);
					continue;
				}
				if (l.top() < x) {
					l.push(x);
					continue;
				}
			}
			if (r.top() <= l.top()) {
				if (l.top() < x) {
					l.push(x);
					continue;
				}
				if (r.top() < x) {
					r.push(x);
					continue;
				}
			}
			cout << "NO" << endl;
			goto a;
		}
		cout << "YES" << endl;
a:;
	}
}

C++: #include<iostream>
int main() {
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i += 1) {
		int N[10];
		for (int i = 0; i < 10; i += 1) 
			std::cin >> N[i];
		if (N[0] == 1 || N[1] == 1)
			std::cout << "YES" << std::endl;
		else
			std::cout << "NO" << std::endl;
	}
	return 0;
}

C++: #include <stdio.h>
??
#define NUM_BALL 10
??
int main(void)
{
????int???????????? n;
????int???????????? num;
????int???????????? left, right;
????int?? flag = 1;
????int???? i, j;
??
????scanf("%d", &n);
????for (i = 0; i < n; i++) {
????????????????left = right = -1;
????????????????for (j = 0; j < NUM_BALL; j++) {
????????????????????????scanf("%d", &num);
????????????????????????if?????????? (num > left) { left?? = num; }
????????????????????????else if (num > right)?????? { right = num; }
????????????????????????else?????? { flag?? = 0; break; }
????????????????}
????????????????puts((flag) ? "YES" : "NO");
????????}
??
????????return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;


int a[10];
int n;

bool dfs(int i,int left, int right){
    if(i==10) return true;
    if(a[i]>left){
        if(dfs(i+1,a[i],right)) return true;
    }
    if(a[i]>right){
        if(dfs(i+1,left,a[i])) return true;
    }
    return false;
}

void solve(){
    for(int i=0;i<10;i++){
        cin>>a[i];
    }
    if(dfs(0,0,0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        solve();
    }
    return 0;
}