#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    bool hantei = true, border[n];
    long long number[n], price[n], quantity[n];
    for (int i = 0; i < n; i++) {
      border[i] = false;
      cin >> number[i] >> price[i] >> quantity[i];
      if (price[i] * quantity[i] >= 1000000) {
        border[i] = true;
      }
    }
    for (int i = 0; i < n; i++) {
      if (border[i]) {
        cout << number[i] << endl;
        hantei = false;
      }
    }
    if (hantei) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
