input_lines = gets.to_i
input_lines.times{
  res = "YES"
  b = []
  c = []
  b.push(0)
  c.push(0)
  s = gets.chomp.split(" ")
  s.map! {|x| x.to_i}
  s.each do |y|
   if b.last < y then
     b.push(y)
   elsif c.last < y then
     c.push(y)
   else
     res = "NO"
     break
   end
  end
puts res
}