#include <bits/stdc++.h>
struct person {
  int num;
  long int value;
  long int volume;
  long int sum;
};
int main(void) {
  int n, i, j;
  int x, y, z;
  int b[4001];
  struct person a[4001];
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    j = 0;
    for (i = 1; i < 4001; i++) b[i] = 0;
    while (n--) {
      scanf("%ld %ld %ld", &x, &y, &z);
      a[x].num = x;
      a[x].value = y;
      a[x].volume = z;
      a[x].sum = a[x].value * a[x].volume;
    }
    for (i = 1; i <= x; i++) {
      if (a[i].sum >= 1000000) {
        b[j] = a[i].num;
        j++;
      }
    }
    if (j == 0) printf("NA\n");
    for (i = 0; i < j; i++) {
      printf("%d\n", b[i]);
    }
  }
  return 0;
}
