#include <bits/stdc++.h>
using namespace std;
int member[4000];
vector<int> ach;
int main(void) {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) break;
    fill(member, member + 4000, 0);
    ach.clear();
    for (int i = 0; i < n; i++) {
      int id, tanka, suryo;
      cin >> id >> tanka >> suryo;
      member[id] += tanka * suryo;
    }
    for (int i = 0; i < 4000; i++) {
      if (member[i] >= 1000000) {
        ach.push_back(i);
      }
    }
    if (ach.empty()) {
      cout << "NA" << endl;
    } else {
      for (int i = 0; i < ach.size(); i++) {
        cout << ach[i] << endl;
      }
    }
  }
  return 0;
}
