n = int(input()) num = [0] * n for i in range(n): g, d = map(int, input().split()) num[i] = [g, d] for i in range(n): g = num[i][0] d = num[i][1] if g - 30000 * d >= 500000: a = i + 1 for j in range(6): print(a) break else: print("NO")