#include<iostream>

using namespace std;

typedef unsigned long long ll;

ll data[4001];
int status;

void print(){
  for(int i = 0; i < 4001; i++)
    if(data[i] >= 1000000){
      cout << i << endl;
      status = 0;
    }
}
int main(){
  ll in;
  while(cin >> in && in){
    status = 1;
    fill(data,data+4001,0);
    for(int i = 0; i < in; i++){
      ll num,p,q;
      cin >> num >> p >> q;
      if(data[num] < 1000000)data[num] += p*q;
    }
    print();
    if(status) cout << "NA" << endl;
  }
  return 0;
}