#include<iostream>

using namespace std;


int main(){

	unsigned long long all[4001] = {};
	unsigned long long code, a, b, n, i, j;

	while (1){
		j = 0;
		for (i = 0; i < 4001; i++){
			all[i] = 0;
		}

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

		for (i = 0; i < n; i++){
			cin >> code >> a >> b;
			all[code] += a*b;
			
		}

		for (i = 0; i < 4001; i++){
			if (all[i] >= 1000000){
				cout << i << endl;
				j++;
			}
		}

		if (j == 0){
			cout << "NA" << endl;
		}

	}
}