#include <bits/stdc++.h>
typedef struct _syain {
  int id;
  long long int uriage;
} syain;
int main(void) {
  int i, n, size;
  int id, tanka, suuryou;
  int j, isfound;
  syain S[4000 + 1];
  while (scanf("%d\n", &n) == 1) {
    if (n == 0) break;
    size = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d\n", &id, &tanka, &suuryou);
      for (j = 0, isfound = 0; j < size; j++) {
        if (S[j].id == id) {
          S[j].uriage += (tanka * suuryou);
          isfound = 1;
        }
      }
      if (isfound == 0) {
        S[size].id = id;
        S[size].uriage = tanka * suuryou;
        size++;
      }
    }
    for (i = 0, isfound = 0; i < size; i++) {
      if (S[i].uriage >= 1000000) {
        printf("%d\n", S[i].id);
        isfound = 1;
      }
    }
    if (isfound == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
