#include <bits/stdc++.h>
int main() {
  int i, j, n, tmp1, tmp2, tmp3, kanribanp = 0;
  int kanri[4000], kanriban[1001];
  char flag;
  while (true) {
    for (i = 0; i < 4000; i++) {
      if (i <= 1001) kanriban[i] = 0;
      kanri[i] = 0;
    }
    scanf("%d", &n);
    printf("N:%d\n", n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      flag = true;
      scanf("%d %d %d", &tmp1, &tmp2, &tmp3);
      for (j = 0; j < kanribanp; j++) {
        if (kanriban[j] == tmp1) flag = false;
      }
      if (flag == true) {
        kanriban[kanribanp] = tmp1;
        kanribanp++;
      }
      if (tmp2 * tmp3 + kanri[tmp1] >= 1000000)
        kanri[tmp1] = 1000000;
      else
        kanri[tmp1] = tmp2 * tmp3 + kanri[tmp1];
    }
    flag = true;
    for (i = 0; i < kanribanp; i++) {
      if (kanri[kanriban[i]] >= 1000000) {
        printf("%d\n", kanriban[i]);
        flag = false;
      }
    }
    if (flag) printf("NA\n");
  }
  return 0;
}
