-- Ball
main = getContents >>= putStr . solve

solve :: String -> String
solve = unlines . map (que [0] [0] . map read . words) . tail . lines
-- solve = unlines . map (dfs 0 0 . map read . words) . tail . lines

dfs :: Int -> Int -> [Int] -> String
dfs _ _ [] = "YES"
dfs l r (x:xs)
  | l < x     = dfs x r xs
  | r < x     = dfs l x xs
  | otherwise = "NO"

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"