#include <iostream>
#include <vector>
#include <map>

using ull = unsigned long long;
const unsigned bound = 1000000;
 

void solve(unsigned n);

int main()
{
	using namespace std;
	unsigned n = 0;
	cin >> n;

	while (n != 0)
	{
		solve(n);
		cin >> n;
	}
	
}

void solve(unsigned n)
{
	using namespace std;
	map<int, ull> records;

	for (int i = 0; i < n; i++)
	{
		int id = 0;
		unsigned price = 0, amount = 0;
		cin >> id >> price >> amount;

		if (records.find(id) == records.end())
			records[id] = ull(price) * ull(amount);
		else
			records[id] += ull(price) * ull(amount);
	}

	vector<int> idList;
	for (auto man : records)
	{
		if (man.second >= bound)
			idList.push_back(man.first);
	}

	if (!idList.empty())
	{
		for (int id : idList)
			cout << id << endl;
	}
	else
	{
		cout << "NA" << endl;
	}
}
