#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void solve100(int n) {
    long officer[4001] = {0};
    long o, p, q;
    REP(i,n) {
        cin >> o >> p >> q;
        officer[o] += p * q;
    }
    int cnt = 0;
    REP(i,4001) {
        if (officer[i] >= 1000000) {
            cnt++;
            cout << i << endl;
        }
    }
    if (cnt == 0) cout << "NA" << endl;
}

int main() {
    int n;
    while(cin >> n, n) {
        solve100(n);
    }
    return 0;
}