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

class Program {
    static void Main() {
        while (true) {
            var n = int.Parse(Console.ReadLine());
            if (n == 0)
                break;

            var sales = new long[4000];
            var ids = new List<int>();

            for (var i = 0; i < n; i++) {
                var l = Console.ReadLine().Split(' ');

                var id = int.Parse(l[0]);
                if (sales[id - 1] == 0) {
                    ids.Append(id);
                }
                long proceeds = long.Parse(l[1]) * int.Parse(l[2]);
                sales[id - 1] += proceeds;
            }

            var found = false;
            foreach (var id in ids) {
                if (sales[id - 1] >= 1000000) {
                    found = true;
                    Console.WriteLine(id);
                }
            }
            if (!found) {
                Console.WriteLine("NA");
            }
        }
    }
}