N=int(input()) A=[input().split() for _ in range(N) ] B=[set(i) for i in zip(*A)]#transpose T={'nyanpass', '-'} if B.count(T)==1:print(B.index(T)+1) else:print(-1)