#include <iostream>
#include <map>
#include <vector>
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;
    vector<int> history;
    int id, price, num;
    for (int i = 0; i < saler_number; i += 1) {
      cin >> id >> price >> num;
      long long tmp = price * num;
      if (result.count(id) == 0) {
        result.insert(make_pair(id,tmp));
        history.push_back(id);
      } else {
        result[id] += tmp;
      }
    }
    //
    bool valid_NA = true;
    for (int i = 0; i < history.size(); i += 1) {
      if (result[history[i]] >= 1000000) {
        cout << history[i] << endl;
        valid_NA = false;
      }
    }
    if (valid_NA) cout << "NA" << endl;
  }
  return 0;
}