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