#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    map<long long, long long> m;
    for (int(i) = 0; (i) < (int)(n); (i)++) {
      long long e, p, q;
      cin >> e >> p >> q;
      if (m.find(e) == m.end())
        m[e] = p * q;
      else
        m[e] += p * q;
    }
    int cnt = 0;
    for (auto itr = m.begin(); itr != m.end(); itr++) {
      if (itr->second >= 1000000) {
        cout << itr->first << endl;
        cnt++;
      }
    }
    if (cnt == 0) cout << "NA" << endl;
  }
  return 0;
}
