import Data.List

main = interact $ unlines . map (show' . ball . map (read::String->Int) . words) . tail . lines
 where show' p = case p of {True -> "YES"; False -> "NO"}

ball ns = or $ map (\n -> let ns' = del_ord n ns in sort ns' == ns') [1..10]
 where
  del_ord :: Int -> [Int] -> [Int]
  del_ord n ns'
   | null ns' = []
   | head ns' == n = del_ord (n+1) (tail ns')
   | otherwise = head ns' : del_ord n (tail ns')