import Control.Applicative
main = do
  _ <- getLine
  s <- lines <$> getContents    
  let v = map (map read . words) s
  let w = map (que [0] [0]) v
  mapM_ putStrLn w
            
que :: [Int] -> [Int] -> [Int] -> String
que _ _ [] = "YES"
que xa@(x:xs) ya@(y:ys) (r:rs)
  | x>=y && r>x = que (r:xa) ya rs
  | r>y         = que xa    (r:ya) rs
  | otherwise = "NO"