#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  int i, p, q;
  while (cin >> N) {
    int check = 0;
    if (!N) break;
    for (int i = 0; i < N; ++i) {
      cin >> i >> p >> q;
      if (p * q >= 1000000) check = 1, cout << i << endl;
    }
    if (check = 0) cout << "NA" << endl;
  }
  return 0;
}
