#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  int id, p, q;
  while (cin >> N) {
    queue<int> que;
    map<int, int> map;
    int check = 0;
    if (!N) break;
    for (int i = 0; i < N; ++i) {
      cin >> id >> p >> q;
      if (map.find(id) == map.end()) {
        map[id] = p * q;
        que.push(id);
      } else {
        map[id] += p * q;
      }
    }
    while (que.size()) {
      if (map[que.front()] >= 1000000) {
        cout << que.front() << endl;
        check = 1;
      }
      que.pop();
    }
    if (check == 0) cout << "NA" << endl;
  }
  return 0;
}
