#include <bits/stdc++.h>
struct worker {
  int id;
  int sales;
};
int main(void) {
  int n;
  int i, j;
  int id, price, quantity;
  int NO_GOOD_WORKERS;
  struct worker worker[4000];
  while (scanf("%d", &n), n != 0) {
    NO_GOOD_WORKERS = 1;
    for (i = 0; i < 4000; i++) {
      worker[i].id = -1;
      worker[i].sales = 0;
    }
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &id, &price, &quantity);
      for (j = 0; j < 4000; j++) {
        if (worker[j].id == id) {
          worker[j].sales += price * quantity;
          break;
        } else if (worker[j].id < 0) {
          worker[j].id = id;
          worker[j].sales += price * quantity;
          break;
        }
      }
    }
    for (i = 0; i < 4000; i++) {
      if (worker[i].sales >= 1000000) {
        if (NO_GOOD_WORKERS) NO_GOOD_WORKERS = 0;
        printf("%d\n", worker[i].id);
      }
      if (worker[i].id < 0) break;
    }
    if (NO_GOOD_WORKERS) printf("NA\n");
  }
  return 0;
}
