#include <bits/stdc++.h>
int main() {
  long long int clerk[4001];
  int n, c;
  while (1) {
    int flag = 0;
    scanf("%d", &n);
    if (n == 0) break;
    for (c = 0; c < 4001; c++) {
      clerk[c] = 0;
    }
    for (c = 0; c < n; c++) {
      int num;
      long long int tanka, suuryou;
      scanf("%d %lld %lld", &num, &tanka, &suuryou);
      clerk[num] += tanka * suuryou;
    }
    for (c = 0; c < 4001; c++) {
      if (clerk[c] >= 1000000) {
        flag = 1;
        printf("%d\n", c);
      }
    }
    if (flag == 0) puts("NA");
  }
  return 0;
}
