def func(b,c,balls)
	
	if balls.length==1&&(balls[0]>b||balls[0]>c) then
		return 1
	elsif balls[0]>b&&balls[0]>c then
		return func(b,balls[0],balls[1..(balls.length-1)])+func(balls[0],c,balls[1..(balls.length-1)])
	elsif balls[0]>c then
		return func(b,balls[0],balls[1..(balls.length-1)])
	elsif balls[0]>b then
		return func(balls[0],c,balls[1..(balls.length-1)])
	else
		return 0
	end
end



n=gets.to_i
dataset=Array.new(n)
n.times{|i|
	dataset[i]=gets.chomp
}
n.times{|i|
	balls=dataset[i].split(" ").map(&:to_i)
	if func(0,0,balls)!=0 then
		dataset[i]=true
	else
		dataset[i]=false
	end
	
}
n.times{|i|
	if dataset[i] then
		puts("Yes")
	else
		puts("No")
	end
}