#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  while (cin >> n, n) {
    map<int, long long> m;
    vector<int> vec;
    long long p, q, s = 0;
    while (n--) {
      cin >> i >> p >> q;
      if (!m[i]) vec.push_back(i);
      m[i] += p * q;
    }
    map<int, long long>::iterator it = m.begin();
    for (int i = 0; i < vec.size(); i++) {
      if (it->second >= 1000000) {
        s = 1;
        cout << it->first << endl;
      }
      it++;
    }
    if (!s) cout << "NA" << endl;
  }
}
