#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int N;
	while (cin >> N) {
		vector<LL>price(4001, 0);
		REP(i, N) {
			int A, B;

			int num;
			cin >> num >> A >> B;
			price[num] += A * B;
		}

		bool flag = false;
		REP(i, 4001) {
			if (price[i] >= 1000000) {
				flag = true;
				cout << i << "\n";
			}
		}

		if (!flag) cout << "NA" << "\n";
	}
	return 0;
}