#include<iostream>
#include<queue>

using namespace std;

int main()
{
	
	while(1)
	{
		int sum = 0;
		int n;
		cin >> n;
		if(n == 0) break;
		
		queue<int> q;
		bool checked[4000];
		int list[4000];
		for(int i = 0;i < 4000;i++)
		{
			checked[i] = false;
			list[i] = 0;
		}
		for(int i = 0;i < n;i++)
		{
			int no, x, y;
			cin >> no >> x >> y;
			list[no] += x * y;
			if(!checked[no] && list[no] >= 1000000)
			{
				q.push(no);
				checked[no] = true;
			}
		}
		
		if(q.empty()) cout << "NA" << endl;
		while(!q.empty())
		{
			cout << q.front() << endl;
			q.pop();
		}
	}
	return 0;
}