import Control.Applicative import Control.Monad import qualified Data.ByteString.Char8 as B import Data.Maybe (fromJust) import Text.Printf import Debug.Trace readInts :: B.ByteString -> [Int] readInts = map (fst . fromJust . B.readInt) . B.words getInts :: IO [Int] getInts = liftM readInts B.getLine f xss n = filter ok [0..(n-1)] where ok i = and $ map (\j -> xss!!j!!i == "nyanpass" || xss!!j!!i == "-") [0..(n-1)] printAns xs = if length xs == 1 then print $ 1 + head xs else print (-1) main = do [n] <- getInts xss <- fmap words <$> replicateM n getLine printAns $ f xss n