$a = []

def solve(n, left, right)
	return true if n == 10 
	return solve(n + 1, $a[n], right) if left < $a[n] 
	return solve(n + 1, left, $a[n]) if right < $a[n]
	false  
end

gets.to_i.times do 
	$a = gets.split.map(&:to_i)

	if solve(0, 0, 0)
		puts "YES"
	else
		puts "NO"
	end
end