import Control.Monad
import Data.List
import Data.Maybe
main = readLn >>= main'
    where
        main' 0 = return ()
        main' n = replicateM n (length <$> getLine) >>= print . solve 1 >> main

solve :: Int -> [Int] -> Int
solve r xxs@(_ : xs) = maybe (solve (r + 1) xs) (const r) $ checkHead xxs >>= checkTail
    where
        checkHead ys = maybeDrop' 5 ys >>= maybeDrop' 7
        checkTail ys = checkHead ys >>= maybeDrop' 7
        maybeDrop' n = innerDrop' 0
            where
                innerDrop' m yys@(y : ys)
                    | m < n = innerDrop' (m + y) ys
                    | m > n = Nothing
                    | otherwise = return yys
                innerDrop' m _
                    | m == n = return []
                    | otherwise = Nothing