object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    in.next
    in.foreach(r =>
        val (_, _, f) = r.foldLeft((0, 0, true))((s, d) => {
            if (s._1 < d) (d, s._2, s._3)
            else if (s._2 < d) (s._1, d, s._3)
            else (s._1, d, s._3 && false)
        })
        if (f) println("YES") else println("NO")
    )
}