#include <bits/stdc++.h>
int member[10000];
unsigned int money[4000];
int in(int n, int c) {
  int i;
  for (int i = 0; i < c; ++i)
    if (member[i] == n) return 1;
  return 0;
}
int main() {
  while (1) {
    int N;
    scanf("%d", &N);
    if (N == 0) break;
    int i, num;
    num = 0;
    for (int i = 0; i < N; ++i) {
      int n, k;
      unsigned int a, b;
      scanf("%d %d %d", &n, &a, &b);
      if ((in(n, num))) {
        money[n] += a * b;
      } else {
        member[num++] = n;
        money[n] = a * b;
      }
    }
    int count = 0;
    for (int i = 0; i < num; ++i) {
      if (money[member[i]] >= 1000000) {
        printf("%d\n", member[i]);
        count++;
      }
    }
    if (count == 0) printf("NA\n");
  }
  return 0;
}
