using System;
using System.Linq;
using System.Collections.Generic;
namespace aizu
{
    class OnlineJudge
    {
        static readonly int Max = 4000;
        public static void Main()
        {
            int count;
            while(int.TryParse(Console.ReadLine(), out count) && count != 0) {
                List<SalesData> data = new List<SalesData>();
                int[] index = new int[Max + 1];
                for(int i=0; i < count; ++i) {
                    int[] value = (from q in Console.ReadLine().Split() select int.Parse(q)).ToArray();
                    if(index[value[0]] == 0) {
                        data.Add(new SalesData { Number = value[0], Sales = value[1] * value[2] });
                        index[value[0]] = data.Count;
                    }
                    else {
                        data[index[value[0]] -1].Sales += value[1] * value[2];
                    }
                }
                int[] output = (from q in data where q.Sales >= 1000000 select q.Number).ToArray();
                if(output.Count() == 0) {
                    Console.WriteLine("NA");
                }
                else {
                    foreach(int number in output) {
                        Console.WriteLine(number);
                    }
                }
            }
        }
    }
    class SalesData
    {
        public int Number { get; set; }
        public int Sales { get; set; }
    }
}