#include<iostream>
#include<map>
#include<string>
using namespace std;
const int MAXN = 4020;
typedef long long ll;
int i,p,q;
bool isfind = false;
map<int,ll> total;
int a[MAXN];


int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0)return 0;
    for(int k = 0;k < n;k++){
      cin >> i >> p >> q;
      total[i] += p*q;
      a[k] = i;
    }
    for(int j = 0;j < n;j++){
      if(total[a[j]] >= 1000000){
	cout << a[j] << endl;
	total[a[j]] = 0;
	isfind = true;
      }
    }
    if(!isfind)cout << "NA" << endl;
    total.clear();
    isfind =false;
  }
  return 0;
}