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