#include <bits/stdc++.h>
int main() {
  int p = 1, tmp0 = 0, ab[4001], name[4001], tmp1 = 0, tmp2 = 0, ansp = 0, tmp3,
      namep0 = 0, ansp0 = 0, tmp4;
  long long int tmp = 0, ans[4001];
  while (p) {
    for (tmp0 = 0; tmp0 < 4001; tmp0++) {
      ab[tmp0] = 0;
      name[tmp0] = 0;
      ans[tmp0] = 0;
    }
    scanf("%d", &p);
    tmp0 = 0;
    ansp = 0;
    ansp0 = 0;
    namep0 = 0;
    while (tmp0 < p) {
      scanf("%d %d %d", &tmp3, &tmp1, &tmp2);
      tmp = tmp1 * tmp2;
      name[namep0] = tmp3;
      namep0++;
      ans[ansp] = tmp1 * tmp2;
      ansp++;
      tmp0++;
    }
    tmp0 = 0;
    while (tmp0 < namep0) {
      tmp4 = tmp0 + 1;
      while (tmp4 < namep0) {
        if (name[tmp0] == name[tmp4]) {
          name[tmp4] = 0;
          ans[tmp0] = ans[tmp0] + ans[tmp4];
        }
        tmp4++;
      }
      tmp0++;
    }
    tmp0 = 0, tmp4 = 0, ansp = 0;
    while (tmp0 < namep0) {
      if (ans[tmp0] >= 1000000 && name[tmp0]) {
        printf("%d\n", name[tmp0]);
        ansp++;
      }
      tmp0++;
    }
    if (ansp == 0 && p) puts("NA");
  }
  return 0;
}
