#include <bits/stdc++.h>
int judge(int id, int j, int set_of_person[]) {
  int i;
  for (i = 0; i < j; i++)
    if (set_of_person[i] == id) return 1;
  return -1;
}
void initialize(int person[], int set_of_person[]) {
  int i;
  for (i = 0; i < 4001; i++) {
    person[i] = 0;
    set_of_person[i] = 0;
  }
}
int main() {
  int i, n, id, price, num, j = 0;
  int person[4001], set_of_person[4001];
  while (scanf("%d", &n)) {
    int na = 0;
    initialize(person, set_of_person);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &id, &price, &num);
      person[id] += price * num;
      if (judge(id, j, set_of_person) == -1) set_of_person[j++] = id;
    }
    for (i = 0; i < j; i++)
      if (person[set_of_person[i]] >= 1000000) {
        printf("%d\n", set_of_person[i]);
        na = 1;
      }
    if (na == 0) printf("NA\n");
  }
  return 0;
}
