#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  while (scanf("%d", &n), n) {
    long long per[5000] = {0};
    int num, t, s;
    int flg = 1;
    for (int i = 0; i < n; i++) {
      scanf("%d%d%d", &num, &t, &s);
      per[num] += (long long)t * (long long)s;
    }
    for (int i = 0; i < 5000; i++) {
      if (per[i] >= (long long)1000000) {
        flg = 0;
        printf("%d\n", i);
      }
    }
    if (flg) puts("NA");
  }
  return 0;
}
