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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            int num;
            while ((num = int.Parse(Console.ReadLine())) != 0)
            {
                var result = Enumerable.Range(0, num)
                             .Select(_ => Console.ReadLine())
                             .Select(
                                 _ =>
                                 {
                                     var data =
                                         _.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                                          .Select(n => int.Parse(n)).ToList();
                                     return new { ID = data[0], Sales = data[1] * data[2] };
                                 }).Where(_ => _.Sales >= 1000000);
                Console.WriteLine(result.Any() ? result.Select(_ => _.ID.ToString()).Aggregate((a, b) => a + Environment.NewLine + b) : "NA");
            }
        }
    }
}