#include <bits/stdc++.h>
int m[4005];
int main() {
  int i, j, n, a, b, c, f;
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    f = 0;
    memset(m, 0, sizeof(m));
    while (n--) {
      scanf("%d%d%d", &a, &b, &c);
      if (m[a] >= 0) {
        if ((1000000 - m[a]) / b <= c) {
          printf("%d\n", a);
          m[a] = -1;
          f = 1;
        } else
          m[a] += b * c;
      }
    }
    if (f == 0) printf("NA\n");
  }
  return 0;
}
