#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n;
  long long int p, q;
  while (cin >> n, n) {
    bool NAflg = false;
    while (n--) {
      cin >> i >> p >> q;
      if ((p * q) >= 1000000) {
        cout << i << endl;
        NAflg = true;
      }
    }
    if (!NAflg) cout << "NA" << endl;
  }
  return 0;
}
