using System;
using System.Linq;

class MainClass
{
   static void Main(string[] args)
   {
      const int employeeCount = 4000;
      const int salesTarget = 1000000;

      int n = int.Parse(Console.ReadLine());
      while (n != 0)
      {   
         int[] sales = new int[employeeCount];
         for (int i = 0; i < n; i++)
         {
            string[] datas = Console.ReadLine().Split(' ');
            int e = int.Parse(datas[0]);
            long p = int.Parse(datas[1]);
            long q = int.Parse(datas[2]);

            long sale = sales[e - 1] + p * q;
            sales[e - 1] = sale >= salesTarget ? salesTarget : (int)sale;
         }

         var overEmployeeNums = from index in Enumerable.Range(0, employeeCount)
                                where sales[index] >= salesTarget
                                select index + 1;
         if (overEmployeeNums.Count() == 0)
         {
            Console.WriteLine("NA");
         }
         else 
         {
            foreach (int index in overEmployeeNums)
            {
               Console.WriteLine(index.ToString());
            }
         }

         n = int.Parse(Console.ReadLine());
      }
   }
}