# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n;
	while (cin >> n&&n) {
		long long member[4001] = {0};
		long long a, b, c;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			member[a] += b*c;
		}
		int count = 0;
		for (int i = 0; i < 4001; i++) {
			if (member[i] >= 1000000) {
				count++;
				cout << i << endl;
			}
		}
		if (count == 0)cout << "NA" << endl;
	}
}