#include <iostream>
using namespace std;

int main()
{
    int n;
    while(cin >> n && n != 0)
    {
        long long  record[4001]={};
        int cnt = 0;
        for(int i=0; i<n; i++)
        {
            int id;
            int p;
            int q;
            cin >> id >> p >> q;
            record[id] += p * q;
        }
        for(int i=1; i<=4000; i++)
        {
            if(record[i] >= 1000000)
            {
                cout << i << endl;
                cnt++;
            }
        }
        if(cnt == 0)
        {
            cout << "NA" << endl;
        }
    }
    return 0;
}