#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  bool f;
  long long int a, b, c;
  map<long long int, long long int> member;
  map<long long int, long long int>::iterator it;
  while (cin >> n, n) {
    member.clear();
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c;
      member[a] += b * c;
    }
    f = true;
    for (it = member.begin(); it != member.end(); it++) {
      if ((*it).second >= 1000000) {
        cout << (*it).first << endl;
        f = false;
      }
    }
    if (f) cout << "NA" << endl;
  }
  return 0;
}
