#include <iostream>
#include <map>

using namespace std;

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        map<int, long long> member;
        for (int i = 0; i < n; i++) {
            int id;
            long long cost, count;
            cin >> id >> cost >> count;
            member[id] += cost * count;
        }
        bool exist = false;
        for (map<int, long long>::iterator m_i = member.begin();
                m_i != member.end(); m_i++) {
            if (m_i->second >= 1000000) {
                cout << m_i->first << endl;
                exist = true;
            }
        }
        if (!exist) {
            cout << "NA" << endl;
        }
    }
    return 0;
}
               

          