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 <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;

#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

typedef long long ll;

int ball[10];
stack<int> r, l;

bool dfs(int n){
    if(n==10) return true;
    bool ret = false;
    // r?????\??????
    int rt = r.top();
    r.push(ball[n]);
    if(r.top()>rt){
        ret |= dfs(n+1);
        r.pop();
    }
    else r.pop();

    int lt = l.top();
    l.push(ball[n]);
    if(l.top()>lt){
        ret |= dfs(n+1);
        l.pop();
    }
    else l.pop();
    return ret;
}

int main(){
    int t;
    cin >> t;
    while(t--){
        while(!r.empty()) r.pop();
        while(!l.empty()) l.pop();
        r.push(0);
        l.push(0);
        FOR(i,0,10) cin >> ball[i];
        if(dfs(0)){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	int n;
	cin>>n;
	vector<int> a(10);
	for(int i=0;i<n;i++){
		queue<int>b,c,d;
for(int j=0;j<10;j++){
	cin>>a[j];
}
for(int j=0;j<10;j++){
	if(b.empty()){
		b.push(a[j]);
	}else if(b.back()<a[j]){
		b.push(a[j]);
	}else if(c.empty()){
		c.push(a[j]);
	}else if(c.back()<a[j]){
		c.push(a[j]);
	}else{
		d.push(a[j]);
	}

}
if(d.empty()){
	cout<<"YES"<<endl;
}else{
	cout<<"NO"<<endl;
}
	}
	return 0;
}

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

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

    int b = 0;
    int c = 0;
    int flag = true;
    for(int j = 0; j < 10; j++) {
      if(data[j] > b) b = data[j];
      else if(data[j] > c) c = data[j];
      else {
	flag = false;
	break;
      }
    }
    if(flag) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int n;
int ball[12],s[12];
bool jud()
{
	int pre=0;
	for(int i=0;i<10;i++)
	 if(!s[i])
	 	if(ball[i]<pre)
	 		return false;
	 	else 
	 		pre=ball[i];
	pre=0;
	for(int i=0;i<10;i++)
	 if(s[i])
	 	if(ball[i]<pre)
	 		return false;
	 	else 
	 		pre=ball[i]; 	
	return true;
}
bool DFS(int x)
{
	if(x==10) return jud();
	if(DFS(x+1)) return true;
	s[x]=1;
	if(DFS(x+1)) return true;
	s[x]=0;
	return false;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		memset(s,0,sizeof(s));
		for(int j=0;j<10;j++)
			scanf("%d",&ball[i]);
		if(DFS(0))
			cout<<"YES"<<endl;
		else 
			cout<<"NO"<<endl;
	}
}

C++: #include<cstdio>
int n,j,lj,F;
int a[15],f[15];
int main()
{
	scanf("%d",&n);
	while(1)
	{
		j=0;F=0;lj=0;
		for(int i=1;i<=10;i++)
		f[i]=0,a[i]=0; 
		for(int i=1;i<=10;i++)
		scanf("%d",&a[i]);
		lj=1;
		for(int i=1;i<=10;i++)
		if(a[i+1]>a[lj]) f[lj]=1,lj=i+1;
		lj=0;
		for(int i=1;i<=10;i++)
		if(!f[i])
		{
			if(a[i]>a[lj]) lj=i;
			else {printf("NO\n");F=1;break;}
		}
		if(F) continue;
		printf("YES\n");
	}
}
/*
#include <iostream>  
  
using namespace std;  
  
const int N = 10;  
  
int main()  
{  
    int n;  
  
    cin >> n;  
    while(n--) {  
        bool ans = true;  
        int a, b=-1, c=-1;  
        for(int i=1; i<=N; i++) {  
            cin >> a;  
            if(ans) {  
                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 n;
	cin>>n;
	
	for(int i=0;i<n;i++){
		int ball[10]={};
		for(int j=0;j<10;j++) cin>>ball[j];
		int a=0,b=0,k;
		for(k=0;k<10;k++){
			if(a<ball[k]) a=ball[k];
			else if(b<ball[k]) b=ball[k];
			else break;
		}
		if(k==10) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
	int N;
	cin>>N; 
	while(N-->0){
		int frist=0,last=0,a;
		string s = "YES";
		for(int i=0;i<10;i++){
			cin>>a;
			if(a>last){
				last = a;
			}else if(a>frist){
				frist = a;
			}else {
				frist = -1;
				s = "NO";
			}
		}
		cout<<s<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
  int data;
  int data_set;
  int box1,box2;
  int i,j,k,l;
  bool f;

  cin>>data_set;
  for(i=0;i<data_set;i++){
    box1=0;
    box2=0;
    f=false;
    for(j=0;j<10;j++){
      cin>>data;
      if(data>box1&&data>box2){
	if(box1<box2){
	  box2=data;
	}else{
	  box1=data;
	}
      }
      else if(data>box1){
	box1=data;
      }
      else if(data>box2){
	box2=data;
      }
      else{
	f=true;
      }
    }
    if(f){
      cout<<"NO"<<endl;
    }else{
      cout<<"YES"<<endl;
    }
  }
  return(0);
}

C++: #include<iostream>
const int nn = 10;
int a[nn];
using namespace std;
bool dfs()
{
	int left = -1;
	int right = -1;
	
	int T = 0;
	while (T<nn)
	{
		if (right < a[T])
		{
			right = a[T++];
			continue;
		}
		if (left < a[T])
		{
			left = a[T++];
			continue;
		}
		return false;
	}
	return true;
}
int main()
{
	//freopen("in.txt", "r", stdin);
	int N;
	scanf("%d", &N);
	while (N--)
	{
		for (int i = 0; i < nn; i++)
			scanf("%d", &a[i]);
		if (dfs())
			printf("YES\n");
		else
			printf("NO\n");
	}

	return 0;
}

C++: #include<iostream>

using namespace std;

char *solve(int d[10])
{
	int l,r;
	l=r=0;
	for(int i=0;i<10;i++)
	{
		if(l>d[i]&&r>d[i])
		{
			return "NO";
		}
		else if(l<d[i]&&r>d[i])
		{
			l=d[i];
		}
		else if(r<d[i]&&l>d[i])
		{
			r=d[i];
		}
		else if(r<l)
		{
			l=d[i];
		}
		else
		{
			r=d[i];
		}
	}
	return "YES";
}

int main(void)
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int d[10];
		for(int j=0;j<10;j++)
		{
			cin>>d[j];
		}
		cout<<solve(d)<<endl;
	}
}

C++: #include<cstdio>
int main()
{
  int n;
  scanf("%d",&n);
  int a[n][10];
  for(int i=0;i<n;i++)
  {
  	for(int j=0;j<10;j++)
	  {
	  	scanf("%d",&a[i][j]);
	  	
			}  	
   }
   
    for(int i=0;i<n;i++)
  {
  	int k=a[i][0];
  	a[i][0]=0;
  	for(int j=0;j<10;j++)
	  {
	    if(a[i][j]>k)
	    {
	    	k=a[i][j];
	    	a[i][j]=0;
		}
			}  	
   }
 
       for(int i=0;i<n;i++)
  {  
    int ins;
  	int count=0;
  	int judge=1;
  	for(int j=0;j<10;j++)
	  {
      if(a[i][j]==0)continue;
      if(count==0)
      {
      	ins=a[i][j];
      	count++;
	  }
      else
      {
      	if(a[i][j]<ins) {
		  judge=0;break;
	}
      	count++;
	  }
		}
		if(judge)printf("YES\n");
		else printf("NO\n");
			}  	
			
			return 0;
   }

C++: #include <cstdio>
int a[10];

bool dfs(int k, int B, int C){
    if(k == 10) return true;
    if(a[k] > B){
        if(dfs(k + 1, a[k], C))
            return true;
    }
    if(a[k] > C){
        if(dfs(k + 1, B, a[k]))
            return true;
    }
    return false;
}

void solve(){
    if(dfs(0, 0, 0))
        printf("YES\n");
    else
        printf("NO\n");
}

int main(int argc, char const *argv[]){

    int t;
    scanf("%d", &t);
    while(t --){
        for(int i = 0; i < 10; i ++)
            scanf("%d", &a[i]);
        solve();
    }

    return 0;
}