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