#include <bits/stdc++.h>
long long int uriage[4000];
int main(void) {
  int n, i, num, flag;
  long long int price, cnt;
  while (scanf("%d", &n)) {
    if (!n) break;
    flag = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %lld %lld", &num, &price, &cnt);
      if (uriage[num - 1] < 1000000) {
        uriage[num - 1] += price * cnt;
        if (uriage[num - 1] >= 1000000) {
          printf("%d\n", num);
          flag = 1;
        }
      }
    }
    if (!flag) printf("NA\n");
  }
  return 0;
}
