#include <bits/stdc++.h>
int main() {
  int n, i;
  double saleResults[4000], employeeID[4000];
  int id;
  double p, q;
  int isOk;
  scanf("%d", &n);
  while (n != 0) {
    isOk = 0;
    for (i = 0; i < 4000; i++) {
      saleResults[i] = 0;
      employeeID[i] = 0;
    }
    for (i = 0; i < n; i++) {
      scanf("%d %lf %lf", &id, &p, &q);
      saleResults[id] += p * q;
      employeeID[id] = 1;
    }
    for (i = 0; i < 4000; i++) {
      if (employeeID[i] == 1 && saleResults[i] >= 1000000) {
        printf("%d\n", i);
        isOk = 1;
      }
    }
    if (!isOk) printf("NA\n");
    scanf("%d", &n);
  }
  return 0;
}
