n = gets.to_i

n.times do
    nums = gets.split.map(&:to_i)
    b = c = 0
    ans = "YES"

    10.times do |i|
#        puts "nums= #{nums[i]} b=#{b}, c = #{c}"
#        puts nums[i] - b
#        puts  nums[i] - c
        sabun_b = (nums[i] - b) < 0 ? 0 : (nums[i] - b)
        sabun_c = (nums[i] - c) < 0 ? 0 : (nums[i] - c)
        if (nums[i] - b < 0) && (nums[i] - c < 0) then
            ans = "NO"
            break;
        elsif b == 0 then
            b = nums[i]
        elsif nums[i] - b < 0 then
            c = nums[i]
        elsif sabun_b > sabun_c then
            c = nums[i]
        else
            b = nums[i]
        end
        
    end

    puts ans
end
