#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A[100000], B, C;
  while (cin >> N, N) {
    int cnt[4001] = {};
    for (int i = 0; i < N; i++) {
      cin >> A[i] >> B >> C;
      cnt[A[i]] += B * C;
    }
    bool NAflag = true, used[4001];
    for (int i = 0; i < N; i++) {
      if (cnt[A[i]] >= 1000000 && used[A[i]] == false) {
        printf("\t%d\n", A[i]);
        used[A[i]] = true;
        NAflag = false;
      }
    }
    if (NAflag == true) puts("\tNA");
  }
  return 0;
}
