from itertools import combinations_with_replacement as cmb NEXT_LEVEL = 3000000 PENALTY = 30000 def round_1h(exp, death): return exp-PENALTY*death N = int(input()) stage = [round_1h(*map(int, input().split())) for x in range(N)] stage = [(i+1, x) for i, x in enumerate(stage) if x > 0] ans = "NO" if stage: for cb in cmb(stage, 6): temp = NEXT_LEVEL lst = [] for i, score in cb: temp -= score lst.append(i) if temp <= 0: ans = "\n".join(map(str, lst)) break print(ans)