#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
pair<int, long long int> s[4001];

int main() {

    int n, id, p, q, idx;
    for (;;) {
        scanf("%d", &n);
        if (n == 0) break;
        for (int i = 0; i < n; i++) { s[i] = {0, 0}; }
        map<int, int> m;
        idx = 0;
        for (int i = 0; i < n; i++) {
            scanf("%d %d %d", &id, &p, &q);
            if (m.find(id) == m.end()) {
                m.insert({id, idx});
                s[idx++] = {id, p*q};
            }
            else {
                s[m[id]].second += p*q;
            }
        }
        bool flag = false;
        for (int i = 0; i < m.size(); i++) {
            if (s[i].second >= 1000000) { flag = true; printf("%d\n", s[i].first); }
        }
        if (!flag) printf("NA\n");
    }

    return 0;
}

