#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  while (cin >> n, n) {
    map<long long, long long> mp;
    vector<long long> v;
    for (int i = 0; i < n; i++) {
      long long e, p, q;
      cin >> e >> p >> q;
      mp[e] += p * q;
      if (!binary_search(v.begin(), v.end(), e)) v.push_back(e);
    }
    bool flag = false;
    for (long long i : v) {
      if (mp[i] >= 1000000) {
        cout << i << endl;
        flag = true;
      }
    }
    if (!flag) puts("NA");
  }
}
