import           Control.Monad
import           Data.Maybe

main :: IO ()
main = do
  n <- readLn
  replicateM_ n $ getLine >>= printResult . solve . map read . words
  where
    printResult True  = putStrLn "YES"
    printResult False = putStrLn "NO"

solve :: [Int] -> Bool
solve = isJust . foldM f (0, 0)
  where
    f (l, r) i
      | l < i     = Just (i, r)
      | r < i     = Just (l, i)
      | otherwise = Nothing