#include <bits/stdc++.h>
int main() {
  int n, num, val, sell, flag, i, j;
  while (1) {
    flag = 0;
    int total[4000] = {};
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = 0; i < n; i++) {
      scanf("%d", &num);
      scanf("%d", &val);
      scanf("%d", &sell);
      total[num] += val * sell;
    }
    for (j = 0; j < 4000; j++) {
      if (total[j] >= 1000000) {
        printf("%d\n", num);
        flag = 1;
      }
    }
    if (flag == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
