#include <bits/stdc++.h>
struct data {
  int num;
  long long pri;
  long long cun;
};
struct ret {
  int num;
  long long sales;
};
int main() {
  while (1) {
    int n;
    std::cin >> n;
    if (n == 0) break;
    std::queue<data> que;
    for (int i = 0; i < n; ++i) {
      data person;
      std::cin >> person.num >> person.pri >> person.cun;
      que.push(person);
    }
    std::vector<ret> lis;
    while (!que.empty()) {
      data perso = que.front();
      if (!lis.empty()) {
        bool f = false;
        for (auto it = lis.begin(); it != lis.end(); ++it) {
          ret pers = *it;
          if (perso.num == pers.num) {
            f = true;
            pers.sales += perso.cun * perso.pri;
            std::swap(pers, *it);
          }
        }
        if (!f) {
          ret newperson;
          newperson.num = perso.num;
          newperson.sales = perso.cun * perso.pri;
          lis.push_back(newperson);
        }
      } else {
        ret newperson;
        newperson.num = perso.num;
        newperson.sales = perso.cun * perso.pri;
        lis.push_back(newperson);
      }
      que.pop();
    }
    bool exist = false;
    for (auto it = lis.begin(); it != lis.end(); ++it) {
      ret per = *it;
      if (per.sales >= 1000000) std::cout << per.num << std::endl, exist = true;
    }
    if (!exist) std::cout << "NA" << std::endl;
  }
  return 0;
}
