#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  int n;
  while(cin >> n,n){
    map<int, long long> m;
    vector<int> order;
    for(int i = 0 ; i < n ; i++ ){
      int id;
      long long a, b;
      cin >> id >> a >> b;
      if( m.find(id) == m.end()){
	order.push_back(id);
	m[id] = a*b;
      }else{
	m[id] += a*b;
      }
    }
    bool isAns = false;
    for(int i = 0; i < (int)order.size(); i++){
      long long money = m[ order[i] ];
      if( money  >= 1000000){
	cout << order[i] << endl;
	isAns = true;
      }
    }
    if( !isAns )cout << "NA" << endl;
  }
  return 0;
}