#include <bits/stdc++.h>
long long int members_number[4001];
int funami;
void reset(void) {
  int i;
  funami = 0;
  for (i = 0; i < 4001; i++) {
    members_number[i] = 0;
  }
}
void check(int staff, int price, int number) {
  int flag = 0;
  if (members_number[staff] < 1000000) {
    members_number[staff] += price * number;
    if (members_number[staff] >= 1000000) {
      printf("%d\n", staff);
      funami = 1;
    }
  }
}
void scan_result(long int n) {
  int staff, number, i, price;
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &staff, &price, &number);
    check(staff, price, number);
  }
}
int main(void) {
  long int n;
  scanf("%ld", &n);
  while (n) {
    reset();
    scan_result(n);
    if (!funami) {
      puts("NA");
    }
    scanf("%ld", &n);
  }
  return 0;
}
