#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  while (~scanf("%d", &num)) {
    if (num == 0) break;
    bool isok = false;
    map<string, int> val;
    vector<string> order;
    for (int i = 0; i < num; i++) {
      char n[16];
      int p, q;
      scanf("%s %d %d", n, &p, &q);
      val[n] += p * q;
      if (find(order.begin(), order.end(), (string)n) == order.end()) {
        order.push_back(n);
      }
    }
    for (vector<string>::iterator it = order.begin(); it != order.end(); it++) {
      if (val[*it] >= 1000000) {
        cout << *it << endl;
        isok = true;
      }
    }
    if (!isok) cout << "NA" << endl;
  }
}
