
#include<bits/stdc++.h>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


typedef long long ll;

vector<int> hoge;
map<int,int> sums;

bool input(){
  hoge.clear();
  sums.clear();
  int n;
  cin>>n;
  if(n==0)return false;
  rep(i,n){
    int a,b,c;
    cin>>a>>b>>c;
    sums[a] += b*c;

  }

  for(auto i:sums){
    if(i.second>=1000000)hoge.push_back(i.first);
  }
  return true;
}

void solve(){

  if(hoge.size()==0)puts("NA");
  else{
    rep(i,hoge.size()){
      printf("%d\n",hoge[i]);
    }
  }
}

int main(){
  while(input()){
    //cout<<solve()<<endl;
    solve();
  }
}