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

typedef pair<int,int> P;

int main(void)
{
	int N;
	while(cin >> N, N){
		P d[4001] = {};
		bool f = false;

		int a,b,c;
		for(int i = 0; i < N; i++){
			cin >> a >> b >> c;

			int j;
			for(j = 0; d[j].first != 0; j++){
				if(d[j].first == a){
					d[j].second += b*c;
					if(d[j].second >= 1000000)
						f = true;
				}
			}
			if(d[j].first == 0){
				d[j].first = a;
				d[j].second += b*c;
			}
		}

		if(!f)
			printf("NA\n");

		else
			for(int i = 0; d[i].first != 0; i++)
				if(d[i].second >= 1000000)
					printf("%d\n", d[i].first);
	}
		





	return 0;
}