#include <iostream>
#include <map>
using namespace std;

typedef long long Int;

int main(){
    map<int,Int> table;
    int n;
    bool flug;

    while(cin >> n, n != 0){
        flug = false;
        table.clear();

        for(int i=1; i<=n; i++){
            int id;
            int tanka;
            int number;
            cin >> id >> tanka >> number;
            table[id] += (tanka*number);
        }

        for(map<int,Int>::iterator itpair = table.begin(); itpair != table.end(); itpair++){
            if(itpair->second >= 1000000){
                cout << itpair->first << endl;
                flug = true;
            }
        }
        if(flug != true){
            cout << "NA" << endl;
        }
    }

    return 0;
}