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

namespace ConsoleApplication40
{
    class Program
    {
        static void Main()
        {
            
            while (true)
            {
                long[] a = new long[4001];
                bool t = true;
                long b = long.Parse(Console.ReadLine());
                if (b == 0) break;
                for(long c = 0; c < b; c++)
                {
                    long[] d = Console.ReadLine().Split().Select(long.Parse).ToArray();
                    a[d[0]] +=( d[1] * d[2]);
                }
                for(long r = 1; r < 4001; r++)
                {
                    if (a[r] >= 1000000) { Console.WriteLine(r); t = false; }
                }
                if (t) Console.WriteLine("NA");
            }
            
        }
    }
}