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