#include <bits/stdc++.h>
#define MAX_MEMBER 4000
#define HIGH 1000000
using namespace std;

int main(void) {
    int n;
    while(cin >> n, n != 0) {
        map<int, int> data;
        bool update = false;
        for(int r = 0; r < n; r++) {
            int no, tanka, quantity;
            cin >> no >> tanka >> quantity;
            if(data[no]) {
                data[no] += tanka*quantity;
            } else data[no] = tanka*quantity;
        }
        for(auto it = data.begin(); it != data.end(); it++) {
            if(it->second >= HIGH) {
                cout << it->first << endl;
                update = true;
            }
        }
        if(!update) cout << "NA" << endl;
    }
    
    return(0);
}