#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int id;
  long long int cost;
  long long int amount;
  long long int sum;
} employee;
int main() {
  long long int n;
  while (cin >> n, n) {
    employee getinp;
    vector<employee> emps;
    for (int i = 0; i < n; i++) {
      cin >> getinp.id >> getinp.cost >> getinp.amount;
      getinp.sum = getinp.cost * getinp.amount;
      if (emps.empty())
        emps.push_back(getinp);
      else {
        for (int j = 0; j < emps.size(); j++) {
          if (emps[j].id == getinp.id) {
            emps[j].sum += getinp.sum;
            break;
          } else if (j == emps.size() - 1) {
            emps.push_back(getinp);
            break;
          }
        }
      }
    }
    int* ids = new int[emps.size()];
    int j = 0;
    for (int i = 0; i < emps.size(); i++) {
      if (emps[i].sum >= 1000000) {
        ids[j] = emps[i].id;
        j++;
      }
    }
    sort(ids, ids + j);
    if (j == 0)
      cout << "NA" << endl;
    else {
      for (int i = 0; i < j; i++) {
        cout << ids[i] << endl;
      }
    }
    delete ids;
  }
  return 0;
}
