#include<iostream>
#include<map>
#include<vector>
#include<string>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;

int main(){
    int n;
    while (cin >> n && n){
        map<string, long long> data;
        vector<string> id;
        rep(i, n){
            string a;
            ll b, c;
            cin >> a >> b >> c;
            ll t = b*c;
            if (data.count(a)){
                data[a] = t;
                id.push_back(a);
            }
            else{
                data[a] += t;
            }
        }

        bool NA = true;
        rep(i, id.size()){
            if (data[id[i]] >= 1000000){
                cout << id[i] << endl;
                NA = false;
            }
        }
        if (NA)
            cout << "NA" << endl;

    }
}