#include<bits/stdc++.h>
using namespace std; 
#define pb push_back
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef vector<int> Vi;

int main()
{
  int n;
  while( cin >> n, n ) {
    int a, b, c;
    map<int, int> m;
    Vi v;
    bool flag = false;
    Rep(i, n) {
      cin >> a >> b >> c;
      if( m.find( a ) == m.end() ) {
	v.pb( a );
	m[a] = 0;
      }
      m[a] += b * c;
    }
    
    Rep(i, v.size()) {
      if( m[v[i]] >= 1000000 ) {
	cout << v[i] << endl;
	flag = true;
      }
    }

    if( !flag ) cout << "NA" << endl;
  }
}