while 1:
    n = int(raw_input())
    if n == 0: break
    table = []
    index = {}
    for k in range(n):
        i, p, q = raw_input().split()
        record = index.get(i)
        if not record:
            record = [i, 0]
            table.append(record)
            index[i] = record
        record[1] += int(p) * int(q)
    found = False
    for record in table:
        if record[1] >= 1000000:
            print record[0]
            found = True
    if not found:
        print 'NA'