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

namespace AOJ.Volume1
{
    class SaleResult
    {
        public static void Main()
        {
            while (true)
            {
                string data_num = Console.ReadLine();
                if (data_num == "0") { break; }

                var sales = new Dictionary<int, long>();
                int cnt = int.Parse(data_num);
                for (int i = 0; i < cnt; i++)
                {
                    var input = Console.ReadLine().Trim().Split(' ');
                    int emp_no = int.Parse(input[0]);
                    int price = int.Parse(input[1]);
                    int qty = int.Parse(input[2]);

                    if (sales.ContainsKey(emp_no)) { sales[emp_no] += price * qty; }
                    else { sales.Add(emp_no, price * qty); }
                }
                var output = sales.Where(x => x.Value >= 1000000).Select(y => y);

                if (output.Count() == 0) { Console.WriteLine("NA"); }
                else
                {
                    foreach (var k in output) { Console.WriteLine(k.Key); }
                }
            }
        }
    }
}