using System;
using System.Collections.Generic;

namespace AOJ0100
{
    class Program
    {
        public Dictionary<int, int> IDs;
        public List<int> target;

        public void Proc()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) continue;
                int N = int.Parse(input);
                if (N == 0) break;

                IDs = new Dictionary<int, int>();

                for (int i = 0; i < N; i++)
                {
                    input = Console.ReadLine();
                    string[] data_s = input.Split(' ');
                    int ID = int.Parse(data_s[0]);
                    int sales = int.Parse(data_s[1]) * int.Parse(data_s[2]);

                    if (IDs.ContainsKey(ID))
                    {
                        IDs[ID] += sales;
                    } else
                    {
                        IDs[ID] = sales;
                    }
                }

                target = new List<int>();

                foreach (KeyValuePair<int, int> pair in IDs)
                {
                    if (pair.Value >= 1000000)
                    {
                        target.Add(pair.Key);
                    }
                }

                if (target.Count == 0)
                {
                    Console.WriteLine("NA");
                    continue;
                }

                for (int i = 0; i < target.Count; i++)
                {
                    Console.WriteLine(target[i]);
                }
            }
        }

        static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }
}