#include <bits/stdc++.h>
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    if (n == 0) break;
    int i, s, t, id, a = 0, d[4000] = {0};
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &id, &t, &s);
      d[id] += t * s;
    }
    for (i = 0; i < 4000; i++) {
      if (1000000 <= d[i]) {
        printf("%d\n", i);
        a = 1;
      }
    }
    if (a == 0) printf("NA\n");
  }
  return 0;
}
