#include <bits/stdc++.h>
using namespace std;
int N, M;
int main() {
  long long goal = 1000000;
  for (; cin >> N;) {
    if (!N) break;
    long long v[4000];
    memset(v, 0, sizeof(v));
    for (int i = 0; i < N; i++) {
      long long e, p, q;
      cin >> e >> p >> q;
      v[e - 1] += p * q;
    }
    bool flag = false;
    for (int i = 0; i < 4000; i++) {
      if (v[i] >= goal) {
        flag = true;
        cout << i + 1 << endl;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
  return 0;
}
