#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
using namespace std;

typedef pair<int, int> P;

int main()
{
	int n, num, val, sale, c;
	P data[4000];
	int flag[4001];
	bool na;
	while(1){
		na = true;
		memset(flag, 0, sizeof(int)*4001);
		c = 1;

		cin >> n;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			cin >> num >> val >> sale;
			if(!flag[num]){
				flag[num] = c;
				data[c].first = num, data[c].second = val * sale;
				c++;
			}else data[flag[num]].second += val * sale;
		}

		for(int i=1; i<c; i++){
			if(data[i].second >= 1000000){
				na = false;
				cout << data[i].first << endl;
			}
		}
		if(na) cout << "NA" << endl;
	}
	return 0;
}