import Control.Applicative ((<$>)) import Control.Monad import Data.List import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B main :: IO () main = do n <- readLn solve <$> replicateM n getss >>= print solve :: [[ByteString]] -> Int solve xss = g . filter (/= 0) . map f $ zip [1..] (transpose xss) where s1 = B.pack "nyanpass" s2 = B.pack "-" f :: (Int, [ByteString]) -> Int f (i, ys) = if all (\y -> y == s1 || y == s2) ys then i else 0 g zs = if length zs == 1 then head zs else (-1) getss :: IO [ByteString] getss = B.words <$> B.getLine