#include <bits/stdc++.h>
using namespace std;
int main(void) {
  map<long long, long long> result;
  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;
    result.clear();
    for (int i = 0; i < n; i++) {
      int id, p, q;
      cin >> id >> p >> q;
      result[id] += p * q;
    }
    bool exist = false;
    map<long long, long long>::iterator i = result.begin();
    for (i; i != result.end(); i++) {
      if ((*i).second >= 1000000) {
        cout << (*i).first << endl;
        exist = true;
      }
    }
    if (!exist) cout << "NA" << endl;
  }
  return 0;
}
