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