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