def dfs(a, b, v, c)
  if c == 10
    return true
  end

  if a < v[c]
    return dfs(v[c], b, v, c+1)
  end

  if b < v[c]
    return dfs(a, v[c], v, c+1)
  end

  return false
end

n = readline.chomp.to_i
n.times{
  v = readline.chomp.split.map{|c| c.to_i}

  if dfs(0, 0, v, 0)
    puts "YES"
  else
    puts "NO"
  end
}