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