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>
int num[10];
int f(int a,int b ,int c) {
	int flag = 0;
	if (a == 9)
		flag = 1;
	if (a == 0)
		return f(1, num[a], 0);
	else if (num[a] > b) {
		if (flag == 1)
			return 1;
		if (num[a] > c)
			return f(a + 1, num[a], c) + f(a + 1, b, num[a]);
		else
			return f(a + 1, num[a], c);
	}
	else if (num[a] > c) {
		if (flag == 1)
			return 1;
		return  f(a + 1, b, num[a]);
	}
	else
		return 0;
}
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];
			num[i] = N[i];
		}
		if (f(0, 0, 0) > 0)
			std::cout << "YES" << std::endl;
		else
			std::cout << "NO" << std::endl;
	}
	return 0;
}

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

using namespace std;

int nums[10];

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

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

	for(;n>0;n--){
		 scanf("%d %d %d %d %d %d %d %d %d %d",&nums[0],&nums[1],&nums[2],&nums[3],&nums[4],&nums[5],&nums[6],&nums[7],&nums[8],&nums[9]);
		 ans = check_recursion(0,0,0);
		 ans ? cout<<"YES"<<endl : cout<<"NO"<<endl;

	}
	return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

// const int kMaxN;

int N;
int D[10];
string ans;

string Search(int i, vector<int> d1, vector<int> d2) {
  if (i == 10) { return "YES"; }

  if (d1.empty() || d1.back() < D[i]) {
    d1.push_back(D[i]);
    if (Search(i+1, d1, d2) == "YES") { return "YES"; }
    d1.pop_back();
  }
  if (d2.empty() || d2.back() < D[i]) {
    d2.push_back(D[i]);
    if (Search(i+1, d1, d2) == "YES") { return "YES"; }
  }

  return "NO";
}

signed main() {
  cin >> N;

  while (N-- > 0) {
    REP(i, 10) { cin >> D[i]; }
    vector<int> d1, d2;
    ans = Search(0, d1, d2);
    cout << ans << endl;
  }

  return 0;
}

C++: #include <cstdio>
int main()
{
 int set[100][10],i,j;
 int t[100]={1};
 scanf("%d",&i);

 for(i=0;i<100;i++)
{
	for(j=0;j<10;j++)scanf("%d",&set[i][j]);
	for(j=0;j<8;j++)
	{
	if(set[i][j+2]<set[i][j+1]&&set[i][j+2]<set[i][j])t[i]=0;
	}
	
	if(t[i]==0)puts("NO");
	if(t[i]==1)puts("YES");
}

return 0;
}

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

int b[10],c[10],bi,ci,flag;

int main()
{
    int n,ball;
    scanf("%d", &n);
    for(int I=0;I<n;++I) {
        for(int i=0;i<10;++i) {
            scanf("%d", &ball);
            if (!bi) { b[bi] = ball; ++bi; continue; }
            else if (!ci) { c[ci] = ball; ++ci; continue; }
            else if (b[bi] < ball) {
                ++bi;
                b[bi] = ball;
                continue;
            } else if (c[ci] < ball) {
                ++ci;
                c[ci] = ball;
                continue;
            } else {
                ++flag;
                break;
            }
        }
        (flag) ? puts("NO") : puts("YES");
    }

    return 0;
}

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

using namespace std;


bool tansaku(vector<int> list,int index,int b,int c)
{
	if (index<10)
	{
		if (b < list[index])
		{
			if (tansaku(list, index + 1, list[index], c))
				return true;
		}
		if (c < list[index])
		{
			if (tansaku(list, index + 1, b, list[index]))
				return true;
		}
	}
	else
	{
		return true;
	}
	return false;
}
int main()
{
	vector<int> s(10);
	int b;

	cin >> b;
	for (int i = 0; i < b; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			cin >> s[j];
		}
		if (tansaku(s, 0, 0, 0))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}

	return 0;
}

C++: #include <stdio.h>

int main(void){
	int topB,topC;
	int n,tmp;
	int valid;
	
	for (scanf("%d", &n); n--;){
		topB=topC=0;
		valid=1;
		for (int i=0; i<10; i++){
			scanf("%d", &tmp);
			if (tmp > topB) topB=tmp;
			else if (tmp > topC)topC=tmp;
			else {
				valid=0; break;
			}
		}
		printf("%s\n",valid?"YES":"NO");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
bool solve(int, int, int);
int a[10];

int main(void){
	int n;
	char t;
	bool flag;
	cin >> n;
	do{
		n--;
		cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8] >> a[9];
		if(solve(0,0,0)){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}while(n != 0);
	return 0;
}

bool solve(int i, int b, int c){
	if(i == 9){
		if(a[i] > b || a[i] > c)
			return (true);
		return(false);
	}
		if(solve(i + 1, a[i], c) || solve(i + 1, b, a[i])){
			return (true);
		}
	return (false);
}

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

int dfs( int, int, int );

int BallData[10];

int main()
{

	int N, ans;

	cin >> N;

	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < 10; j++ ) {
		
			cin >> BallData[j];

			ans = dfs(0, 0, 0);

		}

		if ( ans == 0 ) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
		}

	}
	
	return 0;

}

int dfs( int i, int Left, int Right )
{

	int ans = 0;

	if( i == 10 ) ans = 1;

	if( BallData[i] > Left ) {
		ans = dfs( i + 1, BallData[i], Right );	
	}
	if( BallData[i] > Right ) {
		ans = dfs( i + 1, Left, BallData[i] );
	}

	return ans;

}

C++: // AOJ 0033
#include<cstdio>
#define rep( i, a ) for( int i = 0; i != (a); ++i )

int main()
{
	int N;
	scanf( "%d", &N );

	rep( i, N )
	{
		int l = 0, r = 0;
		bool fl = true;

		rep( j, 10 )
		{
			int a;
			scanf( "%d", &a );

			if( a > l && a > r )
			{
				if( l > r )
					l = a;
				else
					r = a;
			}
			else if( a > l )
				l = a;
			else if( a > r )
				r = a;
			else
			{
				fl = false;
				break;
			}
		}

		puts( fl ? "YES" : "NO" );
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  cin>>n;
  rep(i,n){
    bool ok=true;
    int a,b=0,c=0;
    rep(i,10){
      cin>>a;
      if(a>b)b=a;
      else if(a>c)c=a;
      else ok=false;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}