#include <iostream>
#include <map>

using namespace std;


int main() {
	int n;
	int name, price, number;
	map<int, int> m_Employee;

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

		for (int i = 0; i < n; i++) {
			cin >> name >> price >> number;

			if (m_Employee.count(name)) {
				m_Employee[name] += price * number;
			}
			else {
				m_Employee.insert(map<int, int>::value_type(name, price*number));
			}
		}

		map<int, int>::iterator it = m_Employee.begin();
		bool flag = false;
		while (it != m_Employee.end()) {
			if ((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}

			it++;
		}

		if (!flag) {
			cout << "NA" << endl;
		}

		m_Employee.clear();
	}

	return 0;
}