#include <algorithm>
#include <iostream>
#include <vector>

struct employee {
    int id;
    int price;
    int quantity;

    int total_sales() const {
        return price * quantity;
    }
};

employee read_employee(std::istream& in) {
    employee e{};
    in >> e.id >> e.price >> e.quantity;
    return e;
}

int main() {
    while (std::cin) {
        std::vector<employee> employees;
        int num;
        std::cin >> num;
        if (num <= 0)
            continue;
        for (int i = 0; i < num; ++i) {
            if (!std::cin) {
                std::cerr << "malformed input\n";
                std::exit(1);
            }
            auto e = read_employee(std::cin);
            employees.push_back(e);
        }
        std::vector<int> checked_ids;
        bool na = true;
        for (auto const& employee: employees) {
            if (std::find(checked_ids.begin(), checked_ids.end(), employee.id) != checked_ids.end())
                continue;
            checked_ids.push_back(employee.id);
            int sum = 0;
            for (auto const& e: employees) {
                if (e.id == employee.id)
                    sum += e.total_sales();
            }
            if (sum >= 1000000) {
                std::cout << employee.id << '\n';
                na = false;
            }
        }
        if (na)
            std::cout << "NA\n";
    }
}

