#include <bits/stdc++.h>
int main() {
  int n, i, x, y, z, count;
  while (scanf("%d", &n), n) {
    int data[4100] = {0};
    count = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &x, &y, &z);
      if (y * z >= 1000000) {
        data[count] = x;
        count++;
      }
    }
    if (count == 0)
      printf("NA\n");
    else
      for (i = 0; data[i] != 0; i++) printf("%d\n", data[i]);
  }
  return 0;
}
