#include <bits/stdc++.h>
std::map<int, long long> staff;
std::queue<int> que;
int main() {
  int n;
  while (1) {
    bool isNA = true;
    int number, price, amount;
    std::cin >> n;
    if (n == 0) break;
    staff.clear();
    for (int i = 0; i < n; i++) {
      std::cin >> number >> price >> amount;
      if (staff.find(number) == staff.end()) {
        staff.insert(std::pair<int, long long>(number, price * amount));
        que.push(number);
      } else {
        staff[number] += price * amount;
      }
    }
    while (!que.empty()) {
      if (staff[que.front()] >= 1000000) {
        isNA = false;
        std::cout << que.front() << std::endl;
      }
      que.pop();
    }
    if (isNA) std::cout << "NA" << std::endl;
  }
  return 0;
}
