#include <vector>
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;

int main()
{
    int n, a, b, c;
    while(cin >> n && n) {
        vector<p> v;
        while(n--) {
            cin >> a >> b >> c;
            bool f = true;
            for(int i = 0; i < v.size() ; i++) {
                if(v[i].first == a) {
                    f = false;
                    v[i].second += b * c;
                }
            }
            if(f) {
                v.push_back(p(a, b * c));
            }
        }
        bool f = true;
        for(int i = 0; i < v.size(); i++) {
            if(v[i].second >= 1000000) {
                f = false;
                cout << v[i].first << endl;
            }
        }
        if(f) cout << "NA" << endl;

    }
}