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