#include <bits/stdc++.h>
using namespace std;
map<int, unsigned long long> man;
int main() {
  int n;
  while (cin >> n, n) {
    man = map<int, unsigned long long>();
    for (int i = (0); i < (int)(n); i++) {
      int id, p, n;
      cin >> id >> p >> n;
      man[id] += p * n;
    }
    int c = 0;
    for (auto& m : man) {
      if (m.second >= 1000000) {
        cout << m.first << endl;
        c++;
      }
    }
    if (c == 0) cout << "NA" << endl;
  }
}
