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