#include <bits/stdc++.h>
struct SalesPerformance {
  int number;
  unsigned long sales_price;
  unsigned long sales_volume;
  unsigned long sales_amount;
};
int main(void) {
  int n, i, j, flag1, flag2;
  struct SalesPerformance data[1000];
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    flag1 = 0;
    flag2 = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %lu %lu", &data[i].number, &data[i].sales_price,
            &data[i].sales_volume);
      for (j = 0; j < i; j++) {
        if (data[j].number == data[i].number) {
          data[j].sales_amount += data[i].sales_price * data[i].sales_volume;
          flag1 = 1;
        }
      }
      if (flag1 == 0)
        data[i].sales_amount = data[i].sales_price * data[i].sales_volume;
    }
    for (i = 0; i < n; i++) {
      if (data[i].sales_amount >= 1000000) {
        printf("%d\n", data[i].number);
        flag2 = 1;
      }
    }
    if (flag2 == 0) printf("NA\n");
  }
  return 0;
}
