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