#include <bits/stdc++.h>
using namespace std;
int main() {
  for (int n; cin >> n, n;) {
    vector<long long> id(n), price(n), num(n);
    for (int i = 0; i < n; i++) cin >> id[i] >> price[i] >> num[i];
    int counter = 0;
    for (int i = 0; i < n; i++) {
      if (price[i] * num[i] >= 1000000LL) {
        cout << id[i] << endl;
        counter++;
      }
    }
    if (counter == 0) cout << "NA" << endl;
  }
  return 0;
}
