#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y, z;
  int a = 0;
  int g[4000];
  while (true) {
    int b = 0;
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> x >> y >> z;
      a = y * z;
      if (a >= 1000000) {
        g[i] = x;
        b++;
      }
    }
    if (b > 0) {
      for (int i = 0; i < n; i++) {
        cout << g[i] << endl;
      }
    } else
      cout << "NA" << endl;
  }
  return 0;
}
