#include <iostream>

int main()
{
    bool loop = true;

    while (loop) {
        int dataset_num;
        int count = 0;
        std::cin >> dataset_num;

        if (dataset_num == 0) {
            loop = false;
            break;
        }

        int* officer_num_old = new int[dataset_num];


        for (int i = 0; i < dataset_num; i++) {
            int officer_num = 0;
            int price = 0;
            int figure = 0;
            int flag = 0;

            std::cin >> officer_num;
            std::cin >> price;
            std::cin >> figure;

            for (int j = 0;j < i; j++) {
                if (officer_num_old[j] == officer_num) {
                    flag = 1;
                }
            }


            if (price * figure >= 1000000 && flag == 0) {
                std::cout << officer_num << std::endl;
                count += 1;
            }

            officer_num_old[i] = officer_num;

        }


        if (count == 0) {
            std::cout << "NA" << std::endl;

        }

    }

    return 0;
}