#include<iostream>
#include <sstream>
using namespace std;

struct Saler
{
	int Number;
	int Saled;
};

int main(){
	struct Saler* sl;
	int n, a, b, c, i;
	bool isFound;
	
loop:
	scanf("%d\n", &n);		// データ個数
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * n);
	memcpy(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d\n", &a, &b, &c);
		for(i = 0; i < n; i++)
		{
			if(sl[i].Number == 0)
			{
				sl[i].Number = a;
				sl[i].Saled = b * c;
				break;
			}
			if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		if(sl[i].Saled >= 1000000)
		{
			cout << sl[i].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
end_scope:
    return 0;
}