gets.to_i.times do
  b, c = [], []
  gets.split.map(&:to_i).each do |x|
    case
    when !b.last
      b << x
    when b.last < x
      b << x
    when !c.last || c.last < x
      c << x
    else
      break
    end
  end
  puts b.size + c.size == 10 ? 'YES' : 'NO'
end