using System;
using System.Linq;

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

      int n;
      while ((n = int.Parse(Console.ReadLine())) != 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 = long.Parse(datas[1]);
            long q = long.Parse(datas[2]);

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

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

         foreach (int index in overEmployeeIndexs)
         {
            Console.WriteLine(index.ToString());
         }
      }
   }
}