#include <bits/stdc++.h>
#define HIGH 1000000
#define MEMBER_NUM 4001
#define INF -1
using namespace std;
typedef long long ll;
int main(void) {
    int n;
    while(cin >> n, n != 0) {
        ll data[MEMBER_NUM];
        memset(data, INF, sizeof(data));
        for(int r = 0; r < n; r++) {
            int no;
            ll tanka, quantity;
            cin >> no >> tanka >> quantity;
            if(data[no] != INF) {
                data[no] += tanka*quantity;
            } else {
                data[no] = tanka*quantity;
            }
        }
        bool update = false;
        for(int r = 0; r < MEMBER_NUM; r++) {
            if(data[r] >= HIGH) {
                cout << r << endl;
                update = true;
            }
        }
        if(!update) cout << "NA" << endl;
    }
    return(0);
}