#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){
        vector<pair<int, long long int> > v;
        for(int i=0; i < n; i++){
            int place = -1;
            int p, q, r;
            cin >> p >> q >> r;

            bool isExist = false;
            for(int i=0; i < v.size(); i++){
                if(v[i].first == p){
                    isExist = true;
                    place = i;
                }
            }
            if(!isExist) v.push_back(mp(p, q*r));
            else {
                v[place].second += q*r;
            }
        }
        bool isExist = false;
        for(int i=0; i < v.size(); i++){
            if(1000000 <= v[i].second){
                isExist = true;
                cout << v[i].first << endl;
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}