#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
    int n;

    while(cin>>n,n){
        int id;
        ll p,q;
        vector<ll> v(4001,0);
        priority_queue<int,vector<int>,greater<int>> que;

        while(n--){
            cin>>id>>p>>q;
            if(p*q+v[id]>=1e6){
                que.push(id);
            }else{
                v[id]+=p*q;
            }
        }

        if(que.empty()){
            cout<<"NA"<<endl;
            continue;
        }

        while(!que.empty()){
            cout<<que.top()<<endl;
            que.pop();
        }
    }

    return 0;
}