#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    multimap<int, int, greater<int> > sr;
    for (int i = 0; i < n; ++i) {
      int sn, p, q;
      cin >> sn >> p >> q;
      sr.insert(make_pair(sn, p * q));
    }
    multimap<int, int>::iterator it = sr.begin();
    do {
      if (it == sr.begin() && (*it).second < 1000000) {
        cout << "NA" << endl;
        break;
      }
      cout << (*it).first << endl;
      ++it;
    } while ((*it).second >= 1000000);
  }
}
