#include <bits/stdc++.h>
using namespace std;
int n;
long long int total[1000000];
bool used[1000000];
int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;
    fill(total, total + n + 10, 0);
    fill(used, used + n + 10, false);
    bool found = false;
    while (n--) {
      int id;
      long long int p, q;
      scanf("%d%lld%lld", &id, &p, &q);
      total[id] += p * q;
      if (total[id] >= 1000000 && !used[id]) {
        found = true;
        used[id] = true;
        printf("%d\n", id);
      }
    }
    if (!found) puts("NA");
  }
}
