#include <bits/stdc++.h>
using namespace std;
map<unsigned long long int, unsigned long long int> mp;
int main() {
  int n;
  while (cin >> n, n) {
    mp.clear();
    for (int i = 0; i < n; i++) {
      unsigned long long int a;
      unsigned long long int b, c;
      cin >> a >> b >> c;
      mp[a] += b * c;
    }
    bool isExist = false;
    for (map<unsigned long long int, unsigned long long int>::iterator it =
             mp.begin();
         it != mp.end(); it++) {
      if (it->second >= 1000000) {
        isExist = true;
        cout << it->first << endl;
      }
    }
    if (!isExist) cout << "NA" << endl;
  }
  return 0;
}
