#include <bits/stdc++.h>
using namespace std;
int main() {
  int id, price, num, count, SaleResult[4000];
  bool isBe = false, sameid[4000];
  for (int i = 0; i < 4000; i++) {
    sameid[i] = false;
  }
  while (true) {
    cin >> count;
    if (count == 0) {
      break;
    }
    for (int i = 0; i < count; i++) {
      cin >> id >> price >> num;
      SaleResult[id] += price * num;
      if (SaleResult[id] >= 1000000) {
        if (!sameid[id]) {
          cout << id << '\n';
          isBe = true;
          sameid[id] = true;
        }
      }
    }
    if (!isBe) {
      cout << "NA\n";
    }
    count = 0;
    isBe = false;
    for (int i = 0; i < 4000; i++) {
      SaleResult[i] = 0;
      sameid[i] = false;
    }
  }
  return 0;
}
