#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        map<int, long long int> m;
        vector<int> v;
        for(int i=0; i < n; i++){
            int place = -1;
            int p, q, r;
            cin >> p >> q >> r;

            if(m[p] == 0) v.pb(p);
            m[p] += q*r;
        }
        bool isExist = false;
        for(int i=0; i < v.size(); i++){
            if(1000000 <= m[v[i]]){
                isExist = true;
                cout << v[i] << endl;
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}