#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf_s("%d", &data);
		if (data == 0)break;
		vector<pair<int,int>> company;
		pair<int, int> sells;
		bool hero = false;
		int num, sell, cnt;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			bool search = false;
			for (int j = 0; j < company.size(); j++)
			{
				if (company[j].first == num){
					search = true;
					company[j].second += sell*cnt;
					break;
				}
			}
			if (search == false)
			{
				sells.first = num;
				sells.second = sell*cnt;
				company.push_back(sells);
			}
		}
		for (int i = 0; i < company.size(); i++)
		{
			if (company[i].second >= target)
			{
				hero = true;
				printf("%d\n", company[i].first);
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}