n,k=map(int,input().split()) for i in range(n-1): a,b=map(int,input().split()) if k<=n: print(k-1) else: print(-1)