#include <bits/stdc++.h>
int checkProfit(long int);
typedef struct {
  int Number;
  int price;
  int sold;
  long int profit;
} employee;
int main() {
  employee data[4096];
  int n, i, j, k;
  while (scanf("%d", &n) != EOF) {
    if (n == 0) break;
    k = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &data[i].Number, &data[i].price, &data[i].sold);
    }
    for (i = 0; i < n; i++) {
      data[i].profit = data[i].price * data[i].sold;
    }
    for (i = 0; i < n - 1; i++) {
      for (j = i + 1; j < n; j++) {
        if ((data[i].Number == data[j].Number) && (data[i].profit != 0)) {
          data[i].profit += data[j].profit;
          data[j].profit = 0;
        }
      }
    }
    for (i = 0; i < n; i++) {
      if (checkProfit(data[i].profit) == 1) {
        printf("%d\n", data[i].Number);
        k = 1;
      }
    }
    if (k == 0) printf("NA\n");
  }
  return 0;
}
int checkProfit(long int a) {
  if (a >= 1000000) {
    return 1;
  } else {
    return 0;
  }
}
