#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned long long int ull;

map<ull,ull> mp;

int main() {
  int n;
  
  while(cin>>n, n) {
    mp.clear();
    
    for(int i=0; i<n; i++) {
      ull a;
      ull b, c;
      cin >> a >> b >> c;
      mp[a] += b * c;
    }
    bool isExist = false;
    for(map<ull, ull>::iterator it = mp.begin(); it!=mp.end(); it++) {
      if( it->second >= 1000000 ) {
	isExist = true;
	cout << it->first << endl;
      }
    }
    if( !isExist ) cout << "NA" << endl;
  }
  
  return 0;
}