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