#include <bits/stdc++.h>
struct staff_data {
  int num;
  int price, volume, total;
};
int main(void) {
  int n, i, j, hantei;
  int num, price, volume;
  struct staff_data dt[4000] = {0};
  while (scanf("%d", &n) != 0) {
    if (n == 0) {
      break;
    }
    staff_data dt[4000] = {0};
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &num, &price, &volume);
      for (j = i; j <= i; j++) {
        if (dt[j].num == num || dt[j].num == 0) {
          dt[j].num = num;
          dt[j].total = (price) * (volume) + dt[j].total;
          break;
        }
      }
    }
    hantei = 0;
    for (j = 0; j < n; j++) {
      if (dt[j].total >= 1000000) {
        printf("%4d\n", dt[j].num);
        hantei = 1;
      }
    }
    if (hantei == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
