#include <bits/stdc++.h>
int main(void) {
  int n, f, x, y, z;
  while (scanf("%d", &n), n != 0) {
    f = 1;
    for (; n--;) {
      scanf("%d %d %d", &x, &y, &z);
      if (y * z >= 1000000) printf("%d\n", x), f = 0;
    }
    if (f) printf("NA\n");
  }
  printf("NA\n");
  return 0;
}
