#include <bits/stdc++.h>
typedef struct {
  int number;
  int score;
} DATA;
DATA data[4001];
void init() {
  int i;
  for (i = 0; i < 4001; i++) {
    data[i].score = 0;
    data[i].number = 0;
  }
}
int main() {
  int n, i, j, id, value, amount, count;
  bool flag;
  while (1) {
    init();
    flag = true;
    count = 0;
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &id, &value, &amount);
      for (j = 0; j <= count; j++) {
        if (data[j].number == id) {
          data[j].score += value * amount;
          break;
        }
        if (j == count) {
          data[count].number = id;
          data[count].score += value * amount;
          count++;
          break;
        }
      }
    }
    for (i = 0; i < count; i++) {
      if (data[i].score >= 1000000) {
        printf("%d\n", data[i].number);
        flag = false;
      }
    }
    if (flag) printf("NA\n");
  }
  return 0;
}
