#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  while( cin >> n,n ){
    ll ma[4001] = {0};
    vector<ll>ve;
    ve.clear();
    for(ll k = 0 ; k < n ; k++ ){
      ll a,b,c;
      cin >> a >> b >> c;
      if(ma[a] == 0)ve.push_back(a);
      ma[a] += b*c;
    }
    int f = 1;
    for(vector<ll>::iterator it = ve.begin() ; it != ve.end() ; it++ ){
      if(ma[(*it)] >= 1000000 ){
	cout << (*it) << endl;
	f = 0;
      }
    }
    if(f)cout << "NA" << endl;
  }
  return 0;
}