N=int(raw_input()) L=[] for i in range(N): G,D=map(int,raw_input().split()) L.append((G-D*30000,i+1)) L.sort() L.reverse() if( L[0][0]*6 < 3000000 ): print "NO" else: print "YES" ind=0 cur=0 num=0 while num<6: if cur+L[ind][0]+L[0][0]*(5-ind) >= 3000000: print L[ind][1] cur+=L[ind][0] ind+=1 num+=1 else: ind=0 ind%=N