#include <bits/stdc++.h>
int main() {
  while (1) {
    int n;
    scanf("%d", &n);
    if (n != 0) {
      int i;
      int a, b, c;
      double e[4001] = {};
      int flag = 0;
      for (i = 0; i < n; i++) {
        scanf("%d %d %d", &a, &b, &c);
        e[a] += (double)b * c;
      }
      for (i = 0; i < 4001; i++) {
        if (e[i] >= 1000000) {
          printf("%d\n", i);
          flag++;
        }
      }
      if (flag == 0) printf("NA\n");
    } else {
      break;
    }
  }
  return 0;
}
