n=gets.to_i r=[0]*n n.times{|i|gets;n.times{|j|$_.split[j]=='nyanpass'||i==j||r[j]=p}} p r.count(0)==1?r.index(0)+1:-1