#include <bits/stdc++.h>
int main(void) {
  int a[4000], n, x, y, z, i;
  for (i = 0; i < 4000; i++) a[i] = 0;
  while (scanf("%d", &n), n != 0) {
    i = 1;
    for (; n--;) {
      scanf("%d %d %d", &x, &y, &z);
      if (a[x] < 1000000) {
        a[x] += y * z;
        if (a[x] >= 1000000) printf("%d\n", x), i = 0;
      }
    }
    if (i) printf("NA\n");
  }
  printf("NA\n");
  return 0;
}
