N = int(input()) greeting_table = [ input().split() for _ in range(N) ] renchons = [ i for i, greets in enumerate(zip(*greeting_table), start=1) if all(elem in ('nyanpass', '-') for elem in greets) ] print( renchons[0] if len(renchons) == 1 else -1 )