#include <bits/stdc++.h>
typedef struct {
  int num;
  long long result;
} emp;
int main(void) {
  while (1) {
    emp p[4000];
    int n, i, j, tmp, price, k, count = 0;
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      int flag = 0;
      scanf(" %d %d %d", &tmp, &price, &k);
      long long sell = price * k;
      for (j = 0; j < count; j++) {
        if (p[j].num == tmp) {
          p[j].result += sell;
          flag = 1;
        }
      }
      if (flag == 0) {
        p[count].num = tmp;
        p[count].result = sell;
        count++;
      }
    }
    int ansflag = 0;
    for (i = 0; i < count; i++) {
      if (p[i].result >= 1000000) {
        ansflag = 1;
        printf("%d\n", p[i].num);
      }
    }
    if (ansflag == 0) printf("NA\n");
  }
  return 0;
}
