#include <bits/stdc++.h>
int main(void) {
  int n, i, ban, tan, suu, banmemo[1000] = {0}, bancnt = 0, t;
  long int kin;
  while (scanf("%d", &n)) {
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &ban, &tan, &suu);
      int kensa = 0;
      kin = tan * suu;
      for (t = 0; t < bancnt; t++) {
        if (banmemo[t] == ban) kensa = 1;
      }
      if (kin >= 1000000 && kensa == 0) {
        banmemo[bancnt] = ban;
        bancnt++;
      }
    }
    if (bancnt == 0) {
      puts("NA");
    } else {
      for (t = 0; t < bancnt; t++) {
        printf("%d\n", banmemo[t]);
      }
    }
    bancnt = 0;
  }
  return 0;
}
