#include <iostream>
using namespace std;


int main(void)
{
	int n;

	while(cin >> n,n){
		int d[4000];
		bool f = false;
		fill(d,d+4000,0);

		int no,m,k;
		for(int i = 0; i < n; i++){
			cin >> no >> m >> k;
			d[no-1] += m*k;
		}

		for(int i = 0; i < 4000;i++)
			if(d[i] >= 1000000){
				cout << i+1 << endl;
				f = 1;
			}
		if(!f)
			cout << "NA" << endl;
	}

	

	return 0;
}