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

public class Shain
{
    public int bango { get; set; }
    public long uriage { get; set; }
}


public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var shains = new List<Shain>();
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var shainno = int.Parse(line[0]);
                long uriage = int.Parse(line[1]) * int.Parse(line[2]);
                var a1 = new Shain { bango = shainno, uriage = uriage };
                shains.Add(a1);
            }
            var count = 0;
            var groups = shains.GroupBy(b => b.bango).OrderBy(c => c.Key);
            foreach (var x in groups)
            {
                var mm = x.Sum(z => z.uriage);
                if (mm >= 1000000)
                {
                    count++;
                    Console.WriteLine(x.Key);
                }
            }
            if (count == 0) Console.WriteLine("NA");

        }
    }
}