#include <bits/stdc++.h>
int main(void) {
  int n, i;
  int num, price, qua;
  long sum[4000];
  short int flag;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < 4000; i++) sum[i] = 0;
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &num, &price, &qua);
      if (sum[num] + price * qua >= 1000000)
        sum[num] = 1000000;
      else
        sum[num] += price * qua;
    }
    flag = 0;
    for (i = 0; i < 4000; i++) {
      if (sum[i] >= 1000000) {
        printf("%d\n", i);
        flag = 1;
      }
    }
    if (flag == 0) puts("NA");
  }
  return 0;
}
