N,W=map(int,input().split()) ans=-1 for i in range(N): u,w=map(int,input().split()) if(w