#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

/*
  AOJ :: 0100
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=jp
 */

typedef long long ll;

int main(){
    int n,num,tanka,count,i;
    map<int, pair<int,ll> > mipii;

    while( cin >> n, n ){
        // init
        mipii.clear();

        // input
        rep(i,n){
            cin >> num >> tanka >> count;

            if( mipii.count(num) == 0 ){
                mipii[num] = make_pair(i, (ll)tanka * (ll)count);
            }
            else{
                pair<int,ll> tmp = mipii[num];
                tmp.second = max(tmp.second, (ll)tanka * (ll)count);
                mipii[num] = tmp;
            }
        }

        vector<pair<int,int> > vp;
        foreach(it,mipii){
            if( it->second.second >= 1000000 ){
                vp.push_back(make_pair(it->second.first, it->first));
            }
        }
        sort(all(vp));

        if( vp.size() == 0 ){
            puts("NA");
        }
        else{
            rep(i,vp.size()){
                printf("%d\n",vp[i].second);
            }
        }
    }

    return 0;
}