#include <bits/stdc++.h>
int main(void) {
  int i, n, f, number, u, q, member[4000];
  while (1) {
    f = 0;
    for (i = 0; i < 4000; i++) {
      member[i] = 0;
    }
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &number, &u, &q);
      member[number] = member[number] + (u * q);
    }
    for (i = 1; i < 4000; i++) {
      if (member[i] >= 1000000) {
        printf("%d\n", i);
        f = 1;
      }
    }
    if (f == 0) {
      printf("NA\n");
    }
  }
  return (0);
}
