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

namespace ConsoleApplication58
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                List<long> a = new List<long>();
                long[] g = new long[4001];
                int b = int.Parse(Console.ReadLine());
                if (b == 0)
                    break;
                for (int c = 0; c < b; c++)
                {
                    int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    g[d[0]] += d[1] * d[2];
                }
                for (int h = 0; h < 4001; h++)
                {
                    if (g[h] > 999999)
                        a.Add(h);
                }
                    if (a.Count == 0)
                        Console.WriteLine("NA");
                    else for (int p = 0; p < a.Count; p++)
                            Console.WriteLine(a[p]);
            }
        }
    }
}