#include <iostream>
#include <vector>
using namespace std;

int main() {

	while(true) {

		int n;
		cin >> n;
		if ( n == 0 ) break;

		int score[4000] = {0};
		int num_max = 0;

		for ( int i = 0; i < n; i++ ) {

			int input_number;
			int tanka;
			int kazu;
			cin >> input_number >> tanka >> kazu;

			score[input_number] += tanka * kazu;
			num_max = max( num_max,input_number );

		}

		bool f = true;
		for ( int i = 0; i <= num_max; i++ ) {
			if ( score[i] >= 1000000 ) {
				cout << i << endl;
				f = false;
			}
		}

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

	}

	return 0;
}