#include <iostream>
using namespace std;

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    int number[n];
    bool useN[n];
    long long int total[4000];
    for (int i = 0; i < n; i++) {
      number[n] = 0;
      useN[n] = true;
    }
    for (int i = 0; i < 4000; i++) total[i] = 0;
    
    for (int i = 0; i < n; i++) {
      int a;
      long long int b,c;
      cin >> a >> b >> c;
      number[i] = a;
      for (int j = 0; j < i; j++) {
	if (number[j] == a) {
	  useN[i] = false;
	  break;
	}
      }
      total[a-1] += b*c;
    }
    
    bool NA = true;
    for (int i = 0; i < n; i++) {
      if ( useN[i] && total[number[i]-1] >= 1000000) {
	cout << number[i] << endl;
	NA = false;
      }
    }
    if (NA) cout << "NA" << endl;
  }
  return 0;
}
