#include <bits/stdc++.h>
int main() {
  unsigned long int goukei[4001] = {0}, kazu, tanka;
  int n, i, j, g = 0, kazuz[4001] = {0};
  while (scanf("%d", &n)) {
    if (n == 0) {
      break;
    }
    for (i = 1; i <= n; i++) {
      scanf("%d %d %d", &j, &tanka, &kazu);
      kazuz[i] = j;
      goukei[i] = goukei[i] + tanka * kazu;
    }
    for (i = 1; i < 4001; i++) {
      if (goukei[i] >= 1000000) {
        printf("%d\n", kazuz[i]);
        goukei[i] = 0;
        g++;
      }
    }
    if (g == 0) {
      printf("NA\n");
    }
    g = 0;
  }
  return 0;
}
