#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) break;
    map<int, int> isi;
    int i, p, q;
    for (int j = 0; j < n; j++) {
      cin >> i >> p >> q;
      if (isi.find(i) == isi.end())
        isi[i] = p * q;
      else
        isi[i] += p * q;
    }
    map<int, int>::iterator it;
    bool cc = true;
    for (it = isi.begin(); it != isi.end(); ++it) {
      if (it->second >= 1000000) {
        cout << it->first << endl;
        cc = false;
      }
    }
    if (cc) cout << "NA\n";
  }
  return 0;
}
