#include <bits/stdc++.h>
int main(void) {
  int x[5000], n, a, b, i, nan, k;
  while (0 == 0) {
    scanf("%d", &n);
    if (n == 0) break;
    k = 0;
    for (i = 0; i < 5000; i++) x[i] = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &nan, &a, &b);
      x[nan] += a * b;
      if (x[nan] > 999999) {
        printf("%d\n", nan);
        k++;
      }
    }
    if (k == 0) printf("NA\n");
    k = 0;
  }
  return 0;
}
