#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  while (cin >> N, N) {
    map<int, long long int> mp, mp2;
    vector<int> vi;
    priority_queue<int, vector<int>, greater<int> > pq;
    for (int i = 0; i < N; i++) {
      int num, tanka, suuryo;
      cin >> num >> tanka >> suuryo;
      mp[num] += tanka * suuryo;
      vi.push_back(num);
      if (mp[num] >= 1000000) {
        mp2[num]++;
      }
    }
    vector<int>::iterator it = vi.begin();
    for (; it != vi.end(); it++) {
      if (mp2[*it] >= 2) {
        mp2[*it]--;
      } else if (mp2[*it] == 1) {
        pq.push(*it);
        mp2[*it]--;
      }
    }
    if (pq.empty()) {
      cout << "NA" << endl;
    } else {
      int len = pq.size();
      for (int i = 0; i < len; i++) {
        cout << pq.top() << endl;
        pq.pop();
      }
    }
  }
  return 0;
}
