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