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

int main(){
    long long size, id, price, quantity;
    vector<int> ids;
    bool noone = true;
    while (1){
	cin >> size;
	if (!size) break;
	for (int i = 0; i < size; i++){
	    cin >> id >> price >> quantity;
	    if (price * quantity >= 1000000){
		for (int k = 0; k < ids.size(); k++){
		    if (id == ids[k]) goto HELL;
		}
		cout << id << endl;
		noone = false;
	    }
	  HELL:;
	}
	if (noone) cout << "NA" << endl;
	noone = true;
    }
}