#include <bits/stdc++.h>
int main() {
  int n;
  long long v[4001];
  std::vector<int> vec;
  while (1) {
    std::cin >> n;
    if (!n) break;
    memset(v, 0, sizeof(v));
    vec.clear();
    while (n--) {
      int num;
      int a, b;
      std::cin >> num >> a >> b;
      v[num] += (long long)(a * b);
      vec.push_back(num);
    }
    for (int i = 0; i < 4001; i++) {
      if (v[i] < 1000000)
        v[i] = 0;
      else
        v[i] = 1;
    }
    if (std::count(v + 1, v + 4001, 1) == 0) {
      std::cout << "NA" << std::endl;
    } else {
      std::set<int> s;
      for (std::vector<int>::iterator it = vec.begin(); it != vec.end(); it++) {
        if (v[*it] && s.find(*it) == s.end()) {
          std::cout << *it << std::endl;
        }
        s.insert(*it);
      }
    }
  }
  return 0;
}
