#include <bits/stdc++.h>
int main(void) {
  unsigned long long int a, b, n[4096];
  int i, l, w, y;
  while (scanf("%d", &l), l != 0) {
    y = 1;
    for (i = 0; i <= 4095; i++) n[i] = 0;
    for (i = 1; i <= l; i++) {
      scanf("%d%llu%llu", &w, &a, &b);
      n[w] += (a * b);
    }
    for (i = 0; i <= 4095; i++) {
      if (n[i] >= 1000000) {
        printf("%d\n", i);
        y = 0;
      }
    }
    if (y) printf("NA\n");
  }
  return 0;
}
