#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	queue<int> E;
	map<int, int> R;
	int n, e, p, q;
	while (cin >> n) {
		if (n == 0) break;
		R.clear();
		for (int i = 0; i < n; i++) {
			cin >> e >> p >> q;

			if (R[e] > 0) {
				R[e] += p * q;
			}
			else {
				R[e] = p * q;
				E.push(e);
			}
		}

		bool f = true;
		while (E.size() != 0) {
			int ep = E.front(); E.pop();
			if (R[ep] >= 1000000) {
				cout << ep << endl;
				f = false;
			}
		}

		if (f) cout << "NA" << endl;
	}
}
