#include <bits/stdc++.h>
using namespace std;
int shineN;
int eliteN;
int elite[4000];
int num, tanka, suryo;
int i;
int main() {
  while (1) {
    cin >> shineN;
    if (shineN == 0) {
      break;
    }
    eliteN = 0;
    for (i = 0; i < shineN; i++) {
      cin >> num >> tanka >> suryo;
      if (1000000 <= tanka * suryo) {
        elite[eliteN] = num;
        eliteN++;
      }
    }
    for (i = 0; i < eliteN; i++) {
      cout << elite[i];
    }
    if (eliteN == 0) {
      cout << "NA";
    }
  }
  return 0;
}
