#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 index;
    int id;
    ll c;

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

    bool operator<(const Mem& m) const {
        return index < m.index;
    }
    bool operator==(const Mem& m) const {
        return id == m.id;
    }
    bool operator!=(const Mem& m) const {
        return id == m.id;
    }
};

map<int, ll> m;
map<int, ll>::iterator it;
vector<Mem> ans;
vector<int> index;

int main(void) {
    while(~scanf("%d", &n)) {
        if(n == 0) break;
        m.clear();
        index.clear();
        for(int i = 0; i < n; i++) {
            scanf("%d%d%d", &id, &p, &q);
            amount = p*q;
            m[id] += amount;
            index.push_back(id);
        }
        ans.clear();
        for(it = m.begin(); it != m.end(); it++) {
            if(it->second >= MAX) {
                ans.push_back(Mem((*find(index.begin(), index.end(), it->first)), it->first, it->second));
            }
        }
        sort(ans.begin(), ans.end());
        if(ans.empty()) {
            printf("NA\n");
        } else {
            for(int i = 0; i < (int) ans.size(); i++) {
                printf("%d\n", ans[i].id);
            }
        }
    }
    return 0;
}