while True:
    try:
        num = int(input())
    except:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    tmp = [i for i,j,k in data if j*k >= 1e6]
    seen = set()
    seen_add = seen.add
    result = [x for x in tmp if x not in seen and not seen_add(x)]
    if not result:
        print('NA')
    else:
        [print(r) for r in result]