#include <bits/stdc++.h>
int score[4001];
void init() {
  int i;
  for (i = 1; i < 4001; i++) score[i] = 0;
}
int main() {
  int n, i, number, value, amount;
  bool flag;
  while (1) {
    init();
    flag = true;
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &number, &value, &amount);
      score[number] += value * amount;
    }
    for (i = 1; i < 4001; i++) {
      if (score[i] >= 1000000) {
        printf("%d\n", i);
        flag = false;
      }
    }
    if (flag) printf("NA\n");
  }
  return 0;
}
