#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int n;

int main() {
	while(scanf("%d\n", &n) != EOF) {
		vector<pair<int, ll>> v;
		vector<int> id, p, q;
		rep(i,n) {
			int x, y, z;
			cin >> x >> y >> z;
			id.push_back(x);
			p.push_back(y);
			q.push_back(z);
		}
		rep(i,n) {
			bool flag = false;
			for(vector<pair<int, ll>>::iterator it = v.begin(); it != v.end(); ++it) {
				if((*it).first == id.at(i)) {
					(*it).second += p.at(i) * q.at(i);
					flag = true;
					break;
				}
			}
			if(!flag) {
				v.push_back(make_pair(id.at(i), (ll)p.at(i) * q.at(i)));
			}
		}
		bool flag = false;
		for(vector<pair<int, ll>>::iterator it = v.begin(); it != v.end(); ++it) {
			if((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}