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