#include <bits/stdc++.h>
int main(void) {
  int data;
  int m, n;
  int number;
  long prise, value;
  float money[4000];
  while (1) {
    for (n = 0; n < 4000; n++) {
      money[n] = 0;
    }
    scanf("%d", &data);
    if (data == 0) break;
    for (n = 0; n < data; n++) {
      scanf("%d%d%d", &number, &prise, &value);
      money[number] += (float)prise * value;
    }
    m = 0;
    for (n = 0; n < 4000; n++) {
      if (money[n] >= 1000000) {
        m = 1;
        printf("%d\n", n);
      }
    }
    if (m == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
