#include <iostream>
using namespace std;

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

