#include <cstdio>   /* printf, scanf */
#include <utility>  /* pair, make_pair */
#include <vector>   /* vector */

using namespace std;
int GetContainsNumber(const vector<pair<int, int>> v, const int e) {

    int i = 0;
    for (vector<pair<int, int>>::const_iterator it = v.begin(); it != v.end(); it++) {
        if (e == it->first) {
            return i;
        }
        i++;
    }
    return -1;
}

int main()
{
    int n = 0, e = 0, p = 0, q = 0;
    vector<pair<int, int>> vec;
    while (true) {
        scanf("%d", &n);
        if(0 == n)
            break;

        bool isFind = false;
        for (int i = 0; i < n; i++) {
            scanf("%d%d%d", &e, &p, &q);
            int idx = GetContainsNumber(vec, e);
            if (-1 == idx) {
                vec.push_back(make_pair(e, p * q));
            }
            else {
                vec[idx].second += p * q;
            }
        }

        for (vector<pair<int, int>>::iterator it = vec.begin(); it != vec.end(); it++) {
            if (1000000 <= it->second) {
                printf("%d\n", it->first);
                isFind = true;
            }
        }

        if (!isFind) {
            printf("NA\n");
        }
        vec.clear();
    }

    return 0;
}

