#include <iostream>

const long long BORDER = 1000000;

using namespace std;

int main() {
  bool f;
  int i, j, n, number, price, amount;
  int numbers[4000];
  long long sales[4000];

  for(;;) {
    cin >> n;
    if (n == 0) break;
    for (i = 0; i < 4000; i++) {
      numbers[i] = 0;
      sales[i] = 0;
    }
    for (i = 0, f = false; i < n; i++) {
      cin >> number >> price >> amount;
      for (j = 0; j < i; j++) {
        if (numbers[j] == number) {
          f = true;
          sales[j] = (long long)price * (long long)amount;
        }
      }
      if(!f) {
        numbers[i] = number;
        sales[i] = (long long)price * (long long)amount;
      }
    }
    for (i = 0, f = false; i < n; i++) {
      if (sales[i] > BORDER) {
        f = true;
        cout << numbers[i] << endl;
      }
    }
    if (!f) cout << "NA" << endl;
  }

  return 0;
}