#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  int no = 0;
  long long price = 0;
  long long saleNum = 0;
  bool flg = false;
  map<int, long long> proceed;
  map<int, long long>::iterator ite;
  while (true) {
    flg = false;
    proceed.clear();
    scanf("%d", &n);
    if (0 == n) {
      break;
    }
    for (int i = 0; i < n; ++i) {
      scanf("%d %lld %lld", &no, &price, &saleNum);
      proceed[no] += price * saleNum;
    }
    for (ite = proceed.begin(); ite != proceed.end(); ++ite) {
      if (1000000llu <= ite->second) {
        printf("%d\n", ite->first);
        flg = true;
      }
    }
    if (!flg) {
      printf("NA\n");
    }
  }
}
