#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;
    }
};

int main(){
    int n;
    while( cin >> n, n ){
        vector< data > ls;
        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;
                    break;
                }
            }
            if( it == ls.end() ){
                ls.push_back( data(a, b*c) );
            }
        }
        bool exs = false;
        for(vector<data>::iterator it = ls.begin(); it != ls.end(); it++){
            if( it->sales >= 1000000 ){
                cout << it->id << endl;
                exs = true;
            }
        }
        if( !exs ){
            cout << "NA" << endl;
        }
    }
    return 0;
}