#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, num, tanka, count, i;
  vector<int> ans;
  set<int> S;
  while (cin >> n, n) {
    S.clear();
    ans.clear();
    for (i = 0; i < n; i++) {
      cin >> num >> tanka >> count;
      if ((long long)tanka * (long long)count >= 1000000 && S.count(num) == 0) {
        S.insert(num);
        ans.push_back(num);
      }
    }
    if (ans.size() == 0) {
      puts("NA");
    } else {
      for (i = 0; i < ans.size(); i++) {
        printf("%d\n", ans[i]);
      }
    }
  }
  return 0;
}
