#include <bits/stdc++.h>
int main() {
  typedef struct ch_t {
    int num;
    int NUM;
    int tanka;
    int kazu;
    long long int uriage;
    int flag;
  };
  int n, i, j;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    struct ch_t ch[n];
    int a = 0;
    for (i = 0; i < n; i++) {
      ch[i].num = 0;
      ch[i].uriage = 0;
      ch[i].NUM = i;
      ch[i].flag = 0;
      ch[i].tanka = 0;
      ch[i].kazu = 0;
    }
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &ch[i].num, &ch[i].tanka, &ch[i].kazu);
      for (j = 0; j < n; j++) {
        if (ch[i].num == ch[j].num) {
          ch[ch[j].NUM].uriage += ch[i].tanka * ch[i].kazu;
          break;
        }
      }
    }
    for (i = 0; i < n; i++) {
      if (ch[i].uriage >= 1000000) {
        ch[i].flag = 1;
        a = 1;
      }
    }
    for (i = 0; i < n; i++) {
      if (ch[i].flag == 1) {
        printf("%d\n", ch[i].num);
      }
    }
    if (a == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
