#include <bits/stdc++.h>
using namespace std;
struct staff {
  int num;
  int price;
  int quan;
  int total;
};
int main() {
  int num, i, k, j, datas;
  int sn, sp, sq;
  map<int, staff> staffs[4000];
  datas = 0;
  while (1) {
    cin >> num;
    if (num == 0) break;
    for (i = 0; i < num; i++) {
      cin >> sn >> sp >> sq;
      staffs[datas][sn].num = sn;
      staffs[datas][sn].price = sp;
      staffs[datas][sn].quan = sq;
      staffs[datas][sn].total +=
          staffs[datas][sn].price * staffs[datas][sn].quan;
    }
    datas++;
  }
  map<int, staff>::iterator staffs_it;
  for (i = 0; i < datas; i++) {
    staffs_it = staffs[i].begin();
    int over = 0;
    while (staffs_it != staffs[i].end()) {
      if (staffs[i][(*staffs_it).first].total >= 1000000) {
        cout << staffs[i][(*staffs_it).first].num << endl;
        over++;
      }
      staffs_it++;
    }
    if (over == 0) cout << "NA" << endl;
  }
}
