using System;
using System.Linq;
using System.Collections.Generic;
namespace aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            int count;
            while(int.TryParse(Console.ReadLine(), out count) && count != 0){
                Dictionary<int, int> slaves = new Dictionary<int, int>();
                for(int i=0;i < count;++i){
                    var input = (from q in Console.ReadLine().Split() select int.Parse(q)).ToArray<int>();
                    if(slaves.ContainsKey(input[0])){
                        slaves[input[0]] += input[1] * input[2];
                    }
                    else{
                        slaves.Add(input[0], input[1] * input[2]);
                    }
                }
                var people = (from q in slaves where q.Value >= 1000000 select q.Key).ToList();
                if(people.Count() == 0){
                    Console.WriteLine("NA");
                }
                else{
                    foreach(var person in people){
                        Console.WriteLine(person);
                    }
                }
            }
        }
    }
}