import           Control.Monad

main :: IO ()
main = getLine >> getContents >>= mapM_ (printResult . solve . map read . words) . lines
  where
    printResult (Just _) = putStrLn "YES"
    printResult Nothing  = putStrLn "NO"

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