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")
		}
	}
}

Python: import sys

def solve(balls):
    ans = distribute(balls, [], [])
    if ans is True: print('YES')
    else: print("NO")
        
def distribute(balls, R, L):    
    if len(balls) != 0:
        next = balls[0]
        ans = False
        #case R
        if isMutch(next, R):
            neoR = R
            neoR.append(next)
            ans = distribute(balls[1:], neoR, L)
        if ans: return True
        
        if isMutch(next, L):
            neoL = L
            neoL.append(next)
            ans =distribute(balls[1:], R, neoL)
        if ans: return True
    else:
        return isOrdered(R) and isOrdered(L)

def isMutch(next, lis):
    if len(lis) != 0:
        return next >= lis[len(lis)-1]
    return True
    
def isOrdered(lis):
    #check both R and L are ordered
    checker = sorted(lis)
    return checker == lis
  
limit = 2**11
sys.setrecursionlimit(limit)
  
line = input()
size = -1;
while True:
    if size == -1:
        size = int(line)
    else:
        balls = []
        for a in line.split(' '):
            balls.append(int(a))   
        solve(balls)
        size -= 1
        if size == 0: break
    line = input()

Python: # Aizu Problem 0033: Ball
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N = int(input())
for n in range(N):
    balls = [int(_) for _ in input().split()][::-1]
    left, right = [0], [0]
    fail = False
    while len(balls) > 0:
        ball = balls.pop()
        if ball > left[-1]:
            left.append(ball)
        elif ball > right[-1]:
            right.append(ball)
        else:
            fail = True
            break
    print("YES" if not fail else "NO")

Python: BALL_NUM = 10


def main():
    n = int(input())
    while n > 0:
        balls = list(map(int, input().split()))
        if dfs(balls, 0, 0):
            print("YES")
        else:
            print("NO")

        n -= 1


def dfs(balls, b, c):
    if len(balls) == 1:
        if balls[0] > b or balls[0] > c:
            return True
        else:
            return False

    # ????????????b?????\????????´???
    if balls[0] > b and dfs(balls[1:], balls[0], c):
        return True
    # ????????????c?????\????????´???
    if balls[0] > c and dfs(balls[1:], b, balls[0]):
        return True

    return False


if __name__ == '__main__':
    main()

Python: def main():
    n = int(input())
    for i in range(n):
        Ball = map(int,input().split())
        l = r = 0
        for value in Ball:
            if value > r:
                r = value
            elif value > l:
                l = value
            else:
                print("NO")
                r = -777
                break
            if r < l:
                r,l = l,r
            
        if r == -777:
            continue
        else:
            print("Yes")

if __name__ == '__main__':
    main()

Python: N = int(input())

for testCase in range(N):
    A = list(map(int, input().split()))
    ok = False
    for i in range(2 ** 10):
        x = []
        y = []
        for j in range(10):
            print(j)
            if i & (1 << j):
                x.append(A[j])
            else:
                y.append(A[j])
        if x == sorted(x) and y == sorted(y):
            ok = True
    if ok:
        print('YES')
    else:
        print('NO')

Python: N = input()
for x in range(int(N)):
    B = map(int, input().split())
    a = b = 0
    for y in B:
        if y > a:
            a = y
        elif y > b:
            b = y
        else:
            print('NO')
            a = -1
            break
        if a < b:
            a, b = b, a
    if a == -1:
        continue
    else:
        print('YES')

Python: N = int(input())
for _ in range(N):
    balls = list(map(int, input().split()))
    B, C = [0], [0]
    ans = 1
    for i in range(10):
        b = balls[i]
        if b > B[-1]:
            B.append(b)
        else:
            if b > C[-1]:
                C.append(b)
            else:
                ans = 0
                break
    print("YES" if ans else "NO")

Python: def dfs(i, b, c):
    if i == 10:
        b_sort = sorted(b)
        c_sort = sorted(c)
        return (b == b_sort and c == c_sort)

    if dfs(i + 1, b + [balls[i - 1]], c):
        return True

    if dfs(i + 1, b, c + [balls[i - 1]]):
        return True

    return False


if __name__ == '__main__':
    N = int(input())
    for i in range(N):
        balls = list(map(int, input().split()))
        if dfs(1, [0], [0]):
            print("YES")
        else:
            print("NO")

Python: n = int(input())
for i in range(n):
    B = 0
    C = 0
    A = [int(i) for i in input().split()]
    ans = 'YES'
    for v in A:
        if B > v and C > v:
            ans = 'NO'
            break
        elif B < v and C < v:
            if B > C:
                B = v
            else:
                C = v
        elif B < v:
            B = v
        else:
            C = v
    print(ans)

Python: n = int(input())
for _ in range(n):
    data = list(map(int, input().split()))
    B, C = 0, 0
    flag = True
    for d in data:
        if B < d:
            B = d
        elif C < d:
            C = d
        else:
            print("NO")
            flag = False
            break
    if flag:
        print("YES")

Python: def bl(l):
    b=[]
    c=[]
    for (i,j) in enumerate(l):
        if(i==0):b.extend([j])
        elif(j>b[-1]):b.extend([j])
        elif(c and j>c[-1] and j<b[-1]):c.extend([j])
        elif(not c):c.extend([j])
        else:return 0
    return 1

l=[list(map(int,input().split())) for i in range(int(input()))]
[print("YES") if bl(i) else print("NO") for i in l]

Python: # -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def dfs(balls,B=-1,C=-1,cp=0):
	if cp==len(balls): 	return True
	ball = balls[cp]
	if B<ball:
		is_find = dfs(balls,ball,C,cp+1)
		if is_find: return True
	if C<ball:
		is_find = dfs(balls,B,ball,cp+1)
		if is_find: return True
	return False

def main():
	N = int(input().strip())
	for _ in range(N):
		balls = list(map(int,input().split(' ')))
		is_find = dfs(balls)
		if is_find:		print('YES')
		else:			print('NO')

if __name__=='__main__':
	main()

"""
2
3 1 4 2 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1
"""

Python: for _ in range(int(input())):
    a=b=c=0
    for x in map(int,input().split()):
        if x>b:b=x
        elif x>c:c=x
        else:a=1
    print(['YES','NO'][a])

Python: def judge(data):
    num = list(map(int,data.split()))
    a,b = 0,0
    for i in range(10):
        if a <= num[i]:
            a = num[i]
        elif b <= num[i]:
            b = num[i]
        else:
            print('NO')
            return 0
    print('YES')
    return 0
            
n = int(input())
array = [0]*n
for i in range(n):
    array[i] = input()

for i in range(n):
    judge(array[i])

Python: n = int(input())
for i in range(n):
    l = list(map(int, input().split()))
    k,c= l[0], 0
    for j in l:
        if j < k:
            c += 1
            k = j
    if 2 <= c:
        print("NO")
    else:
        print("YES")