#include <bits/stdc++.h>
using namespace std;
int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;
    map<string, int> mpa;
    for (int i = 0; i < n; i++) {
      string e;
      int p, q;
      cin >> e;
      cin >> p >> q;
      mpa[e] += p * q;
    }
    map<string, int>::iterator itr;
    bool flag = false;
    for (itr = mpa.begin(); itr != mpa.end(); itr++) {
      if (itr->second >= 1e6) {
        cout << itr->first << endl;
        flag = true;
      }
    }
    if (flag == false) cout << "NA" << endl;
  }
  return 0;
}
