num=[]

for i in 1..gets.to_i
    num=gets.split(nil).map(&:to_i)
    b=c=0
    for t in 0...num.size
        if (b<num[t])&&(b-c>=0)
            b=num[t]
        elsif (c<num[t])
            c=num[t]
        else
            puts "NO"
            break
        end
        puts "YES" if (t==num.size-1)
    end
end