#include <bits/stdc++.h>
using namespace std;
int n;
long long need = (int)1e6;
long long sum[4040];
int main() {
  while (1) {
    cin >> n;
    if (n == 0) break;
    memset(sum, 0, sizeof(sum));
    for (int i = 0; i < n; i++) {
      int id, q, p;
      cin >> id >> q >> p;
      sum[id] += q * p;
    }
    bool na = true;
    for (int i = 0; i < 4040; i++) {
      if (sum[i] >= need) {
        cout << i << endl;
        na = false;
      }
    }
    if (na) cout << "NA" << endl;
  }
  return 0;
}
