#include <bits/stdc++.h>
int main(void) {
  int i, count;
  int data, number, tanka[4000], kosu[4000], hozon[4000];
  long long int uriage[4000];
  while (1) {
    for (i = 0; i < 4000; i++) uriage[i] = 0;
    count = 0;
    scanf("%d", &data);
    if (data != 0) {
      for (i = 0; i < data; i++) {
        scanf("%d", &number);
        scanf("%d %d", &tanka[number - 1], &kosu[number - 1]);
        uriage[number - 1] =
            uriage[number - 1] + (tanka[number - 1] * kosu[number - 1]);
        hozon[i] = number;
      }
      for (i = 0; i < data; i++) {
        if (uriage[hozon[i] - 1] >= 1000000) {
          printf("%d\n", hozon[i]);
          count++;
        }
      }
      if (count == 0) printf("NA\n");
    } else
      break;
  }
  return 0;
}
