#include <iostream>

int main(void)
{
    int n, e, p, q;
    int employee[4000] = {0};

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

        while(n--)
        {
            std::cin >> e >> p >> q;
            employee[e - 1] += (p * q);
        }

        int cnt = 0;
        for(int i = 0; i < 4000; ++i)
        {
            cnt += (employee[i] >= 1000000);
        }

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

        else
        {
            for(int i = 0; i < 4000; ++i)
            {
                if(employee[i] >= 1000000)
                {
                    employee[i] = 0;
                    std::cout << i + 1 << std::endl;
                }
            }
        }
    }

    return 0;
}