#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n;
  while(cin>>n,n){
    map<int,int> M;
    REP(i,n){
      int e,p,q;
      cin>>e>>p>>q;
      M[e]+=p*q;
    }
    bool f=false;
    for(auto itr=M.begin();itr!=M.end();itr++){
      if((itr->second)>=1000000){
        cout<<(itr->first)<<endl;
        f=true;
      }
    }
    if(!f)cout<<"NA"<<endl;
  }
  return 0;
}