#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <sstream>
#include <map>

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){
        // id, ord, sell
        map<int, pair<int,int>> m;
        int c = 0;
        rep(i, n){
            ll id, unit, num;
            cin >> id >> unit >> num;
            if (m.count(id)==0){
                m[id].first = c++;
            }
            m[id].second += unit * num;
        }
        vector<pair<int,int>> ans;
        for (auto & p : m){
            if (p.second.second >= 1000000){
                ans.push_back(make_pair(p.second.first, p.first));
            }
        }
        sort(ans.begin(), ans.end());
        if (ans.size()){
            rep(i, ans.size()){
                cout << ans[i].second << endl;
            }
        }
        else{
            cout << "NA" << endl;
        }
    }
}