#include <bits/stdc++.h>
struct E {
  int id;
  int sum;
};
int getNo(struct E *employee, int id) {
  int index = 0;
  while (employee[index].id != 0) {
    index++;
  }
  return index;
}
int main(void) {
  int n, i, index;
  int id, price, amount;
  struct E employee[4001];
  int flag;
  while (scanf("%d", &n)) {
    if (n == 0) break;
    bzero(employee, sizeof(struct E) * 4001);
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &id, &price, &amount);
      index = getNo(employee, id);
      employee[index].id = id;
      employee[index].sum += (price * amount);
    }
    flag = 0;
    for (i = 0; i < 4001; i++) {
      if (employee[i].sum >= 1000000) {
        printf("%d\n", employee[i].id);
        flag = 1;
      }
    }
    if (flag == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
