import Control.Applicative
import Control.Monad

main = do
  n <- (read::String->Int) <$> getLine
  v <- replicateM n ((map read . words) <$> getLine)
  mapM_ putStrLn $ map (que [0] [0]) v
            
que :: [Int] -> [Int] -> [Int] -> String
que _ _ [] = "YES"
que xa@(x:xs) ya@(y:ys) (r:rs)
  | r>x = que (r:xa) ya rs
  | r>y = que xa     (r:ya) rs
  | otherwise         = "NO"