#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    queue<int> q;   
    while(cin >> n){
        if(n==0) break;
        map<int,ll> data;
        vector<int> memo(n);
        rep(i,n){
            int number;
            cin >> number;
            memo[i] = number;
            ll p,q;
            cin >> p >> q;
            data[number] += (p*q);
        }
        bool ok = false;
        rep(i,n){
            if(data[memo[i]] >= 1000000){ q.push(memo[i]); ok = true; data[memo[i]]=0; }
        }
        if(!ok) q.push(-1);
    }
    while(!q.empty()){
        if(q.front()<0) cout << "NA" << endl;
        else cout << q.front() << endl;
        q.pop();
    }
    return 0;
}
