import Control.Monad (foldM, replicateM_)
import Data.Maybe (isJust)

main = do
    n <- readLn
    replicateM_ n (input >>= return . solve >>= output)

input :: IO [Int]
input = (map read . words) `fmap` getLine

output :: Bool -> IO ()
output b = putStrLn $ if b then "YES" else "NO"

solve :: [Int] -> Bool
solve = isJust . foldM push (0,0)
    where
    push (a,b) c
        | a < c = Just (c, b)
        | b < c = Just (a, c)
        | otherwise = Nothing