using System;
namespace aizu
{
    public class No0100
    {
        public static void Main()
        {
            int count;
            while(int.TryParse(Console.ReadLine(), out count) && count != 0) {
                int[] value = new int[4000];
                int[] index = new int[4000];
                int use = 0;
                for(int i=0; i < count; ++i) {
                    string[] input = Console.ReadLine().Split();
                    int number = int.Parse(input[0]);
                    int sale = int.Parse(input[1]) * int.Parse(input[2]);
                    if(value[number-1] == 0) {
                        index[use++] = number;
                    }
                    value[number-1] += sale;
                }
                int output = 0;
                for(int i=0; i < use; ++i) {
                    if(value[index[i]-1] >= 1000000) {
                        Console.WriteLine(index[i]);
                        ++output;
                    }
                }
                if(output == 0) {
                    Console.WriteLine("NA");
                }
            }
        }
    }
}