#include <iostream>
#include <map>
using namespace std;
int main (int argc, char const* argv[]) {
  int saler_number;
  while (true) {
    cin >> saler_number;
    if (saler_number == 0) break;
    map<int,long long> result;
    int id, price, num;
    for (int i = 0; i < saler_number; i += 1) {
      cin >> id >> price >> num;
      if (result.count(id) == 0) {
        result.insert(make_pair(id,price * num));
      } else {
        result[id] += price * num;
      }
    }
    //
    bool valid_NA = true;
    map<int,long long>::iterator it = result.begin();
    while (it != result.end()) {
      if (it->second >= 1000000) {
        cout << it->first << endl;
        valid_NA = false;
      }
      //cout << it->first << ":" << it->second << endl;
      it++;
    }
    if (valid_NA) cout << "NA" << endl;
  }
  return 0;
}