#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int id;
    long long p, q;
    vector<long long> v(4001, 0);
    priority_queue<int, vector<int>, greater<int>> que;
    while (n--) {
      cin >> id >> p >> q;
      if (p * q + v[id] >= 1e6) {
        que.push(id);
      } else {
        v[id] += p * q;
      }
    }
    if (que.empty()) {
      cout << "NA" << endl;
      continue;
    }
    while (!que.empty()) {
      cout << que.top() << endl;
      que.pop();
    }
  }
  return 0;
}
