#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u){
	stringstream ss;
	ss << t;
	ss >> u;
}

int main(){
	int n;
	while(cin >> n && n!=0){
		map<int, ll> ans;
		vector<int> idx;
		int id, price, num;
		for(int i = 0; i < n; i++){
			cin >> id >> price >> num;
			if(!ans.count(id)) idx.push_back(id);
			ans[id] += price*num;
		}

		vector<int> ans_id;
		for(int i = 0; i < idx.size(); i++){
			if(ans[idx[i]]>=1000000) ans_id.push_back(idx[i]);
		}
		if(ans_id.size()==0){
			cout << "NA" << endl;
		}else{
			for(int i = 0; i < ans_id.size(); i++){
				cout << ans_id[i] << endl;
			}
		}
	}
	return 0;
}