#include <iostream>
#include <map>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

map<int,unsigned long long> man;

int main(){
    int n;
    while(cin>>n,n){
        man=map<int,unsigned long long>();
        rep(i,n){
            int id,p,n; cin>>id>>p>>n;
            man[id]+=p*n;
        }
        int c=0;
        for(auto&m:man){
            if(m.second>=1000000){
                cout<<m.first<<endl;
                c++;
            }
        }
        if(c==0) cout<<"NA"<<endl;
    }
}