using System;
using System.Linq;

static class Const
{
   public const int employeeCount = 4000;
}

class MainClass
{
   static void Main(string[] args)
   {
      int n = int.Parse(Console.ReadLine());
      while (n != 0)
      {   
         var sales = new int[Const.employeeCount];
         for (int i = 0; i < n; i++)
         {
            string[] datas = Console.ReadLine().Split(' ');
            var e = int.Parse(datas[0]);
            var p = int.Parse(datas[1]);
            var q = int.Parse(datas[2]);

            sales[e] += p * q;
         }

         var overEmployeeIndex = from index in Enumerable.Range(0, Const.employeeCount)
                                 where sales[index] >= 1000000
                                 select index;
         if (overEmployeeIndex.Count() == 0)
         {
            Console.WriteLine("NA");
         }
         else 
         {
            foreach (var index in overEmployeeIndex)
            {
               Console.WriteLine(index.ToString());
            }
         }

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