#include <bits/stdc++.h>
using namespace std;
int ans[4000];
int main() {
  int N;
  int n;
  long long int e, p, q;
  int x;
  while (1) {
    x = 0;
    cin >> N;
    n = N;
    if (N == 0) {
      break;
    }
    while (N) {
      cin >> e >> p >> q;
      cout << N << x << endl;
      if (p * q >= 1000000) {
        ans[x] = e;
        x++;
      }
      N--;
    }
    for (int i = 0; i < n; i++) {
      if (i == 0 && ans[i] == 0) cout << "NA" << endl;
      if (ans[i] == 0) {
        break;
      }
      cout << ans[i] << endl;
    }
  }
  return 0;
}
