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

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