n=gets.to_i
n.times{
	ball=gets.chomp.split(" ").map{|s| s.to_i}
	b0=0
	b1=0
	ok=1
	10.times{|i|
		if ball[i]>b0 then
			b0=ball[i]
		elsif ball[i]>b1 then
			b1=ball[i]
		else 
			ok=0
			break
		end
	}
	if ok==0 then 
		puts "NO"
	else
		puts "YES"
	end
}
