#include<iostream>
#include<map>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    int a;
    long long b,c;
    map<int, long long> sale;
    sale.clear();
    bool f = true;
    while(n--){
      cin >>a>>b>>c;
      sale[a]+=b*c;
    }
    for(map<int, long long>::iterator pos = sale.begin(); pos!=sale.end(); pos++){
      if(pos->second >= 1000000){cout <<pos->first<<endl;f = false;}
    }
    if(f){cout <<"NA"<<endl;}
  }
  return 0;
}