using System;
using System.Linq;

namespace _0100
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                ulong[] Result = new ulong[4001];
                for (int i = 0; i < n; i++)
                {
                    ulong[] x = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
                    if (Result[x[0]] < 1000000)
                    {
                        Result[x[0]] += x[1] * x[2];
                    }
                }
                bool find = true;
                for (int i = 0; i <= 4000; i++)
                {
                    if (Result[i] >= 1000000)
                    {
                        Console.WriteLine(i);
                        find = false;
                    }
                }
                if (find)
                {
                    Console.WriteLine("NA");
                }
            }
        }
    }
}