#include <bits/stdc++.h>
long long N[4001];
int f[4001];
int main() {
  int x, n, p, i, j, c = 0;
  scanf("%d", &i);
  while (i != 0) {
    c = 0;
    for (j = 0; j < i; j++) {
      scanf("%d%d%d", &x, &n, &p);
      if (N[x] != -1) {
        N[x] += n * p;
        if (N[x] >= 1000000) {
          f[c] = x;
          c++;
          N[x] = -1;
        }
      }
    }
    if (c == 0)
      printf("NA\n");
    else
      for (j = 0; j < c; j++) printf("%d\n", f[j]);
    memset(N, 0L, 4001);
    memset(f, 0, 4001);
    scanf("%d", &i);
  }
}
