#include <bits/stdc++.h>
int main(void) {
  long long i, j, k, l;
  long long n;
  long long flag;
  long long data[3];
  long long judge[4000] = {0};
  long long src[4000];
  while (1) {
    k = 0;
    memset(src, 0, sizeof(src));
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &data[0], &data[1], &data[2]);
      flag = 0;
      for (j = 0; j < k + 1; j++) {
        if (data[0] == judge[j]) {
          src[j] += data[1] * data[2];
          flag = 1;
        }
      }
      if (flag == 0) {
        judge[k] = data[0];
        src[k] += data[1] * data[2];
        k++;
      }
    }
    flag = 0;
    for (i = 0; i < k + 1; i++) {
      if (src[i] >= 1000000) {
        printf("%d\n", judge[i]);
        flag = 1;
      }
    }
    if (flag == 0) {
      printf("NA\n");
    }
  }
  return (0);
}
