import Control.Applicative ((<$>)) import Control.Monad (replicateM) import Data.List (sortBy, group) main :: IO () main = do t <- readLn solve <$> replicateM t (getLine >> map read <$> words <$> getLine) >>= mapM_ print solve :: [[Int]] -> [Int] solve = map (f 0 . map length . group . sort) where f ct xs | length xs < 3 = ct | otherwise = let ss = sort xs (as, bs) = splitAt 3 ss in f (ct+1) ((filter (>0) . map (subtract 1)) as ++ bs) sort :: [Int] -> [Int] sort = sortBy (flip compare)