#include <iostream>
#include <map>
using namespace std;
 
int main() {
    int n;
    while(cin >> n && n) {
        map<int, int> M;
        while(n-- > 0) {
            int a, b, c;
            cin >> a >> b >> c;
            M[a] += b * c;
        }
        bool b = false;
        for(map<int, int>::iterator it = M.begin(); it != M.end(); it++)
            if (it->second >= 1000000)
                cout << it->first << endl, b = true;
        if (!b)
            cout << "NA" << endl;
    }
    return 0;
}