#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int n, s, t, u, p;
  bool f, a[4001];
  pair<int, long long int> pa[4001];
  while (1) {
    cin >> n;
    if (n == 0) {
      break;
    }
    fill(a, a + 4000, true);
    for (int i = 0; i < n; i++) {
      cin >> s >> t >> u;
      pa[i].first = s;
      pa[i].second = t * u;
    }
    f = true;
    for (int i = 0; i < n; i++) {
      if (pa[i].second >= 1000000 && a[pa[i].first]) {
        cout << pa[i].first << endl;
        a[pa[i].first] = false;
        f = false;
      }
    }
    if (f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
