#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<map>
using namespace std;

int main(){

	while (true) {
		int cnt = 0;
		cin >> cnt;
		if (cnt == 0) break;

		std::map<int, int> data;
		for (int i = 0; i < cnt; ++i) {
			int id, price, amount;
			cin >> id >> price >> amount;
			int g = price * amount;

			if (data.find(id) == data.end()) data[id] = 0;
			data[id] += g;
		}
		bool bHitted = false;
		for (std::map<int, int>::iterator it = data.begin(); it != data.end(); ++it) {
			// cout << "--" << it->first << ", " << it->second << "\n";
			if (it->second >= 1000000) {
				cout << it->first << "\n";
				bHitted = true;
			}
		}
		if (!bHitted) {
			cout << "NA\n";
		}
	}
	return 0;
}