#include <vector>
#include <iostream>
#include <set>
#include <string>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        set<string> list;
        string id;
        ll a,b,c = 1000000;
        for(int i = 0; i < n; i++) {
            cin >> id >> a >> b;
            if(a * b >= c && list.find(id) == list.end()) {
                list.insert(id);
                cout << id << endl;
            }
        }
        if(list.size() == 0) cout << "NA" << endl;
    }
}