#include <bits/stdc++.h>
using namespace std;
static const double PI = 6 * asin(0.5);
long long n;
int main() {
  while (cin >> n, n != 0) {
    map<long long, long long> id;
    vector<long long> a;
    for (int i = 0; i < int(n); ++i) {
      long long t1, t2, t3;
      a.push_back(t1);
      cin >> t1 >> t2 >> t3;
      id[t1] += t2 * t3;
    }
    bool f = true;
    for (int i = 0; i < int(a.size()); ++i) {
      if (id[a[i]] >= 1000000) {
        cout << a[i] << endl;
        id[a[i]] = 0;
        f = false;
      }
    }
    if (f) cout << "NA" << endl;
  }
  return 0;
}
