print((lambda rs: rs[0] if len(rs) == 1 else -1)((lambda N: [i for i, gs in enumerate(zip(*[input().split() for _ in range(N)]), start=1) if all(e in ('nyanpass', '-') for e in gs)])(int(input()))))