#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, e;
  long p, q;
  map<int, long> mp;
  map<int, long>::iterator itr;
  while (cin >> n) {
    if (n == 0) break;
    for (int i = 0; i < n; ++i) {
      cin >> e >> p >> q;
      itr = mp.find(e);
      if (itr != mp.end()) {
        mp[e] += p * q;
      } else {
        mp[e] = p * q;
      }
    }
    bool isNA = true;
    for (itr = mp.begin(); itr != mp.end(); ++itr) {
      if (itr->second >= 1000000) {
        cout << itr->first << endl;
        isNA = false;
      }
    }
    if (isNA) {
      cout << "NA" << endl;
    }
    mp.clear();
  }
  return 0;
}
