# -*- coding: utf-8 -*-

import sys
import os
import math
from collections import defaultdict

for s in sys.stdin:
    n = int(s)
    if n == 0:
        break

    d = defaultdict(int)
    keys = []
    for i in range(n):
        e, p, q = map(int, input().split())
        d[e] += p * q
        if e not in keys:
            keys.append(e)

    # remove dup
    is_exist = False

    for key in keys:
        v = d[key]
        if v >= 1000000:
            print(key)
            is_exist = True

    if not is_exist:
        print('NA')