def f(i, l, r)
  return true if i == 10
  return f(i+1, $b[i], r) if l < $b[i]
  return f(i+1, l, $b[i]) if r < $b[i]
  return false
end

gets.to_i.times do
  $b = gets.split.map(&:to_i)
  puts f(0,0,0) ? "YES" : "NO"
end