#include <iostream>
#include <map>

using namespace std;

int main()
{
    const int TARGET = 1000000;
    map<int, int> sale;
    int n_data, id, amount, price, n_target;
    for (;;) {
	cin >> n_data;
	if (n_data == 0)
	    break;
	for (int i = 0; i != n_data; ++i) {
	    cin >> id >> price >> amount;
	    sale[id] += price * amount;
	}
	map<int, int>::iterator it = sale.begin();
	n_target = 0;
	while (it != sale.end()) {
 	    if (it->second >= TARGET) {
		cout << it->first << endl;
		++n_target;
	    }
	    ++it;
	}
	if (n_target == 0)
	    cout << "NA" << endl;
	sale.clear();
    }
}