using System;
using System.Collections.Generic;
using System.Linq;

class Employee
{
   public static int employeeCount => 4000;
   public static long salesTarget => 1000000L;

   public Employee(int index)
   {
      this.index = index;
   }

   public int index;
   public long sales;
}

class MainClass
{
   static void Main(string[] args)
   {

      int n;
      while ((n = int.Parse(Console.ReadLine())) != 0)
      {
         var employees = new List<Employee>();
         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]);

            var employee = employees.Find(x => x.index == e);
            if (employee == null) {
               employee = new Employee(e);
               employees.Add(employee);
            }
            employee.sales += p * q;
         }

         var overEmployees = employees.FindAll(x => x.sales >= Employee.salesTarget);
         if (overEmployees.Count == 0)
         {
            Console.WriteLine("NA");
            continue;
         }

         foreach (var employee in overEmployees)
         {
            Console.WriteLine(employee.index.ToString());
         }
      }
   }
}