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

namespace AOJ0100
{
    class Program
    {
        static void Main()
        {
            ReadInputs()
                .Select(
                    s =>
                        s.GroupBy(r => r.Id,
                            (id, records) => new {Id = id, Sales = records.Sum(r => r.UnitPrice*r.Quantity)})
                            .Where(t => t.Sales >= 1000000)
                            .Select(t => t.Id.ToString())
                            .DefaultIfEmpty("NA"))
                .ForEach(results => results.ForEach(Console.WriteLine));

        }

        private static IEnumerable<IEnumerable<Record>> ReadInputs()
        {
            
            IEnumerable<Record> dataSet;
            while ((dataSet = ReadDataSet()) != null)
            {
                yield return dataSet;
            }

        }

        private static IEnumerable<Record> ReadDataSet()
        {
            var count = int.Parse(Console.ReadLine() ?? "0");
            return count == 0 ? null : ReadDataSetImpl(count);
        }

        private static IEnumerable<Record> ReadDataSetImpl(int count)
        {
            while (count-- > 0)
            {
                // ReSharper disable once PossibleNullReferenceException
                var data = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                yield return new Record {Id = data[0], UnitPrice = data[1], Quantity = data[2]};
            }
        }
    }

    class Record
    {
        public int Id { get; set; }
        public int UnitPrice { get; set; }
        public int Quantity { get; set; }
    }

    static class EnumerableExtensions
    {
        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
        }
    }
}