using System;
using System.Linq;
using System.Collections.Generic;
namespace aizu
{
    public class No0100
    {
        public static void Main()
        {
            string countString;
            while((countString = Console.ReadLine()) != string.Empty && countString != "0") {
                int count = int.Parse(countString);
                if(count == 0) {
                    break;
                }
                int[] value = Enumerable.Repeat<int>(-1, 4000).ToArray();
                List<int> numbers = new List<int>(4000);
                for(int i=0; i < count; ++i) {
                    int[] input = (from q in Console.ReadLine().Split() select int.Parse(q)).ToArray<int>();
                    if(value[input[0]] == -1) {
                        numbers.Add(input[0]);
                        value[input[0]] = 0;
                    }
                    value[input[0]] += input[1] * input[2];
                }
                List<int> output = (from q in numbers where value[q] >= 1000000 select q).ToList();
                if(output.Count == 0) {
                    Console.WriteLine("NA");
                }
                else {
                    output.ForEach(number => Console.WriteLine(number));
                }
            }
        }
    }
}