#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    if (n == 0) {
      break;
    };
    int number[n], price[n], value[n];
    for (int i = 0; i < n; i++) {
      cin >> number[i] >> price[i] >> value[i];
    }
    int total[n], NA;
    for (int i = 0; i < n; i++) {
      total[n] = price[i] * value[i];
      if (total[n] >= 1000000) {
        cout << number[i] << endl;
        NA = 1;
      }
    }
    if (NA != 1) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
