using System;
using System.Linq;
using System.Collections.Generic;
namespace aizu
{
    public class OnlineJudge
    {
        public static void Main()
        {
            int count;
            while(int.TryParse(Console.ReadLine(), out count) && count != 0) {
                int[] value = new int[4001];
                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();
                    if(value[input[0]] == 0) {
                        numbers.Add(input[0]);
                    }
                    value[input[0]] += input[1] * input[2];
                }
                bool output = false;
                foreach(int number in numbers) {
                    if(value[number] >= 1000000) {
                        Console.WriteLine(number);
                        output = true;
                    }
                }
                if(output == false) {
                    Console.WriteLine("NA");
                }
            }
        }
    }
}