from sys import stdin

if __name__ == '__main__':
    for line in stdin:
        if int(line) == 0:
            break

        isEmpty = True
        record = {}
        for _ in range(int(line)):
            employee = input().split(' ')
            total = int(employee[1]) * int(employee[2])

            if total >= 1000000:
                print(employee[0])
                isEmpty = False
            else:
                e_t = record.get(employee[0])

                if e_t:
                    e_t = record.get(employee[0]) + total
                    if e_t >= 1000000:
                        print(employee[0])
                        isEmpty = False
                    else:
                        record[employee[0]] = e_t

                else:
                    record[employee[0]] = total

        record.clear()

        if isEmpty:
            print('NA')