#include<iostream>
#include<vector>
#include<map>
#define SALES_GOAL 1000000
using namespace std;
int main(void){
  int i,n;
  vector<int> data;
  vector<int>::iterator vc_it;
  while(cin>>n,n){
    int tof = 1;
    int num,price,qua;
    map<int,long long int> staff;
    map<int,long long int>::iterator itr;
    while(n-- > 0){
      cin >> num >> price >> qua;
      staff[num] = staff[num]? staff[num]+(long long int)price*qua : (long long int)price*qua;

    }
    for(itr = staff.begin(); itr != staff.end(); itr++){

      if(itr->second >= SALES_GOAL){
        data.push_back(itr->first);
        tof = 0;
      }
    }
    if(tof)data.push_back(0);
  }
  for(vc_it = data.begin(); vc_it != data.end(); vc_it++){
    if(*vc_it)cout << *vc_it << endl;
    else cout << "NA" << endl;
  }

}
    