#include <bits/stdc++.h>
int main() {
  int n, m, a[4005], x, y, z, i;
  while (scanf("%d", &n) != EOF) {
    if (n == 0) break;
    m = 0;
    for (i = 0; i < 4001; i++) a[i] = 0;
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &x, &y, &z);
      if (a[x] >= 0) {
        if (a[x] < 1000000) a[x] += y * z;
        if (a[x] >= 1000000) printf("%d\n", x), m++, a[x] *= -1;
      }
    }
    if (m == 0) printf("NA\n");
  }
  return 0;
}
