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