#include <bits/stdc++.h>
long long int uriage[4001];
int main() {
  int i, cnt;
  int code;
  long long int tannka, suuryou;
  int flag;
  while (EOF != scanf(" %d", &cnt) && cnt > 0) {
    for (i = 0; i < 4000; i++) uriage[i] = 0;
    for (i = 0; i < cnt; i++) {
      scanf("%d %ld %ld", &code, &tannka, &suuryou);
      uriage[code] += tannka * suuryou;
    }
    flag = 0;
    for (i = 0; i < 4000; i++)
      if (uriage[i] >= 1000000) {
        flag = 1;
        printf("%d\n", i);
      }
    if (flag == 0) printf("NA\n");
  }
  return (0);
}
