#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;
    for (int i = 0; i < num; i++) {
      char n[16];
      int m, o;
      scanf("%s %d %d", n, &m, &o);
      val[n] += m * o;
    }
    for (map<string, int>::iterator it = val.begin(); it != val.end(); it++) {
      if (it->second >= 1000000) {
        cout << it->first << endl;
        isok = true;
      }
    }
    if (!isok) cout << "NA" << endl;
  }
}
