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