#include <bits/stdc++.h>
int main() {
  int num, age, tanka;
  int i, j, n, temp;
  int sya[4000];
  double uriage[4000];
  for (;; temp = 0) {
    for (i = 0; i < n; i++) uriage[i] = 0;
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &num, &tanka, &age);
      for (j = 0; j <= i; j++) {
        if (sya[j] == num) {
          uriage[j] += tanka * age;
          break;
        } else {
          sya[i] = num;
          uriage[i] += tanka * age;
          break;
        }
      }
    }
    for (i = 0; i < n; i++) {
      if (uriage[i] >= 1000000) {
        printf("%d\n", sya[i]);
        temp = 1;
      }
    }
    if (temp == 0) puts("NA");
  }
  return 0;
}
