#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
int GCD(int a, int b){
    if(b==0) return a;
    return GCD(b, a%b);
}

int main() {
    int n;
    while(cin >> n, n){
        map<ll, ll> mp;
        vector<ll> v;
        for(int i=0; i<n; ++i){
            ll e, p, q; cin >> e >> p >> q;
            mp[e]+=p*q;
            v.push_back(e);
        }
        
        bool check[4010];
        for(int i=0; i<4010; ++i) check[i]=false;
        int cnt=0;
        for(int i=0; i<v.size(); ++i){
            if(mp[v[i]]>=1000000&&!check[v[i]]) {
                cnt++;
                cout << v[i] << endl;
                check[v[i]]=true;
            }
        }
        if(cnt==0) cout << "NA" << endl;
    }
    
    
	return 0;
}
