#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    map<int, long long> worker;
    queue<int> order;
    for (int i = 0; i < n; i++) {
      int id, price, num;
      cin >> id >> price >> num;
      if (worker.find(id) == worker.end()) {
        order.push(id);
      }
      worker[id] += (price * num);
    }
    bool flag = true;
    while (!order.empty()) {
      if (worker[order.front()] >= 1000000) {
        cout << order.front() << endl;
        flag = false;
      }
      order.pop();
    }
    if (flag) {
      cout << "NA" << endl;
    }
  }
}
