using System;
using System.Collections.Generic;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(int i; (i = int.Parse(Console.ReadLine())) != 0;) {
                var employee = new Dictionary<string, long>(4000);
                var excel = new HashSet<string>();
                while(i-- > 0) {
                    var input = Console.ReadLine().Split();
                    var v = int.Parse(input[1]) * int.Parse(input[2]);
                    if(!employee.ContainsKey(input[0])) {
                        if(v >= 1000000) {
                            excel.Add(input[0]);
                        }
                        employee.Add(input[0], v);
                    }
                    else if(!excel.Contains(input[0])) {
                        if((employee[input[0]] += v) >= 1000000) {
                            excel.Add(input[0]);
                        }
                    }
                }
                if(excel.Count > 0) {
                    foreach(var item in excel) {
                        Console.WriteLine(item);
                    }
                }
                else {
                    Console.WriteLine("NA");
                }
            }
        }
    }
}