#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl;
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  ll n,d=1000000;
  while(cin >> n && n)  {
    map<ll,ll> m,m2,m3;
    set<ll> se;
    m.clear();
    m2.clear();
    m3.clear();
    se.clear();
    rep(i,n) {
      ll x,y,z;
      cin >> x >> y >> z;
      if(se.count(x)) {
	m2[m[x]]+=y*z;
      } else {
	m[x]=m.size()+1;
	m3[m[x]]=x;
	se.insert(x);
	m2[m[x]]=y*z;
      }
    }
    bool ck=true;
    tr(it,m2) {
      iter(m3) it2=m3.find(it->F);
      if(it->S>=d) {
	cout <<it2->S << endl;
	ck=false;
      }
    }
    if(ck) pr("NA");
  }
  return 0;
}
