#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
#include <complex>
using namespace std;
 
const double EPS = 1e-9;
const double PI = 3.14159265359;
 
typedef complex<double> P;

typedef long long int li;

int main(){
	int n;

	while(cin >> n, n){
		vector<li> sales(4001);
		int num;
		li tanka, kazu;
		for(int i = 0; i < n; i++){
			cin >> num >> tanka >> kazu;
			sales[num] += tanka*kazu;
		}

		bool NA = true;
		for(int i = 1; i <= 4000; i++){
			if(sales[i] >= 1000000){
				cout << i << endl;
				NA = false;
			}
		}
		if(NA){
			cout << "NA" << endl;
		}
	}

    return 0;
}