#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

struct data{
    int id;
    long long int sales;
    data(int a, long long int b) : id(a), sales(b) {}
    bool operator<( const data& o ) const{
        return id < o.id;
    }
};

bool invec(int id, vector<int> v){
    for(vector<int>::iterator it = v.begin(); it != v.end(); it++){
        if( *it == id ) return true;
    }
    return false;
}

int main(){
    int n;
    while( cin >> n, n ){
        vector< data > ls;
        vector<int> good;
        for(int i = 0; i < n; i++){
            int a, b, c;
            cin >> a >> b >> c;
            vector<data>::iterator it = ls.begin();
            for(; it != ls.end(); it++){
                if( it->id == a ){
                    it->sales += b*c;
                    if( it->sales >= 1000000 &&
                        !invec(it->id, good)){
                        good.push_back( it->id );
                    }
                    break;
                }
            }
            if( it == ls.end() ){
                ls.push_back( data(a, b*c) );
                if( b*c >= 1000000 &&
                    !invec(a, good)){
                    good.push_back( a );
                }
            }
        }
        if( !good.size() ){
            cout << "NA" << endl;
        }else{
            for(vector<int>::iterator it = good.begin(); it != good.end(); it++){
                cout << *it << endl;
            }
        }
    }
    return 0;
}