#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<map>

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define f first
#define s second

using namespace std;

typedef long long ll;

int main(){
  int n;
  while(cin>>n, n){
    map<string,pair<int,ll> > m;
    vector<pair<int,string> > v;
    REP(i,n){
      string a;
      ll b,c;
      cin>>a>>b>>c;
      if(m.find(a) == m.end())
	m[a] = mp(m.size(),b*c);
      else
	m[a].s += b*c;
    }
    FOR(it,m) if(it->s.s >= (ll)1000000) v.push_back(mp(it->s.f,it->f));
    if(v.size() == 0) cout << "NA" << endl;
    else{
      sort(ALL(v));
      FOR(it,v) cout << it->s << endl;
    }
  }
  return 0;
}