#include <iostream>
#include <algorithm>

static const long long TOTAL_NORMA = 1000000;
static const int MAX_WORKER_SIZE = 4000;
static long long m[MAX_WORKER_SIZE];
static bool isShow[MAX_WORKER_SIZE];


int main(void) {
    int n;

    while (std::cin >> n) {
        if (n == 0) {
            return 0;
        }

        // init
        bool f = true;
        std::fill(m, m + (sizeof m / sizeof m[0]), 0);
        std::fill(isShow, isShow + (sizeof isShow / sizeof isShow[0]), false);

        for (int i = 0; i < n; ++i) {
            long long number, price, quantity;
            std::cin >> number >> price >> quantity;

            m[number] += (price * quantity);

            if (isShow[number] == false && TOTAL_NORMA <= m[number]) {
                std::cout << number << std::endl;
                isShow[number] = true;
                f = false;
            }
        }

        if (f) {
            std::cout << "NA" << std::endl;
        }

    }

    return 0;
}