#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int n;
  while (cin >> n, n) {
    map<long long int, long long int> mp;
    for (long long int j = 0; j < n; j++) {
      long long int a, b, c;
      cin >> a >> b >> c;
      mp[a] += b * c;
    }
    bool flag = false;
    for (auto itr = mp.begin(); itr != mp.end(); itr++)
      if (mp[itr->first] >= 1000000) {
        flag = true;
        cout << itr->first << endl;
      }
    if (!flag) cout << "NA" << endl;
  }
}
