#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, num, tanka, count, i;
  set<pair<int, int> > S;
  map<int, int> mii;
  while (cin >> n, n) {
    S.clear();
    mii.clear();
    for (i = 0; i < n; i++) {
      cin >> num >> tanka >> count;
      if (mii.count(num) == 0) {
        mii[num] = i;
      }
      if ((long long)tanka * (long long)count >= 1000000 &&
          S.count(make_pair(mii[num], num)) == 0) {
        S.insert(make_pair(mii[num], num));
      }
    }
    if (S.size() == 0) {
      puts("NA");
    } else {
      for (typeof(S.begin()) it = S.begin(); it != S.end(); it++) {
        printf("%d\n", it->second);
      }
    }
  }
  return 0;
}
