using System;
using System.Collections.Generic;
class _0100
{
    public static void Main()
    {
        bool flag;
        string[] data;
        long sum, val;
        Dictionary<string, long> d = new Dictionary<string, long>();
        List<string> sortDKey;
        int n = int.Parse(Console.ReadLine());
        while (n != 0)
        {
            d.Clear();
            flag = false;
            for (int i = 0; i < n; i++)
            {
                data = Console.ReadLine().Split();
                sum = long.Parse(data[1]) * long.Parse(data[2]);
                if (d.TryGetValue(data[0], out val))
                {
                    d.Remove(data[0]);
                    d.Add(data[0], val + sum);
                }
                else d.Add(data[0], sum);
            }
            sortDKey = new List<string>(d.Keys);
            sortDKey.Sort();
            foreach (string k in sortDKey)
            {
                if(d[k] >= 1000000)
                {
                    flag = (!flag) ? true : flag;
                    Console.WriteLine(k);
                }
            }
            if (!flag) Console.WriteLine("NA");
            n = int.Parse(Console.ReadLine());
        }
    }
}