import Data.List
main = do
	n <- readLn
	getContents	>>= 
		return . map (and . map (=="nyanpass") . tail . sort) . transpose . map words . lines >>=
			\x -> let lst = [i|i<-[1..n], x!!(i-1)] in print $
				if length lst == 1
					then head lst
					else -1