#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    map<long, long> m;
    int i, p, q, s = 0;
    while (n--) {
      cin >> i >> p >> q;
      if (m.find(i) == m.end())
        m.insert(make_pair(i, p * q));
      else
        m[i] += p * q;
    }
    for (map<long, long>::iterator it = m.begin(); it != m.end(); ++it) {
      if (it->second > 999999) {
        s = 1;
        cout << it->first << endl;
      }
    }
    if (!s) cout << "NA" << endl;
  }
}
