#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> total;
  int d, num, item, ko;
  while (cin >> d) {
    if (d == 0) break;
    for (int i = 0; i < d; i++) {
      cin >> num >> item >> ko;
      item *= ko;
      if (item >= 1000000) {
        total.insert(make_pair(num, item));
      }
    }
    if (total.size() == 0)
      cout << "NA" << endl;
    else {
      map<int, int>::iterator it;
      for (it = total.begin(); it != total.end(); it++) {
        cout << (*it).first << endl;
      }
      total.clear();
    }
  }
}
