#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;

int n, id, p, q;
ll amount;

const ll MAX = 1000000;

struct Mem {
    int id;
    ll c;

    Mem() {}
    Mem(int _id, ll _c) { id = _id; _c = c; }
};

Mem array[4010];
vector<int> ans;

int main(void) {
    while(~scanf("%d", &n)) {
        if(n == 0) break; ans.clear();
        for(int i = 0; i < n; i++) {
            array[i].c = array[i].id = 0;
            scanf("%d%d%d", &id, &p, &q);
            array[i].c = p * q;
            array[i].id = id;
        }
        for(int i = 0; i < n; i++) {
            ll cost = 0;
            for(int j = 0; j < n; j++) {
                if(array[i].id == array[j].id) {
                    cost += array[j].c;
                }
            }
            if(cost >= MAX && !count(ans.begin(), ans.end(), array[i].id)) {
                ans.push_back(array[i].id);
            }
        }
        if(ans.empty()) {
            printf("NA\n");
        } else {
            for(int i = 0; i < (int) ans.size(); i++) {
                printf("%d\n", ans[i]);
            }
        }
    }
    return 0;
}