#include <bits/stdc++.h>
using namespace std;
bool AOJ0100() {
  long long int n, e, p, q;
  cin >> n;
  if (n == 0) return false;
  long long int* data = new long long int[4001];
  for (int i = 0; i <= 4000; i++) data[i] = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> e >> p >> q;
    data[e] += p * q;
  }
  bool flag = false;
  for (int i = 1; i <= 4000; i++) {
    if (data[i] >= 1000000) {
      flag = true;
      cout << i << endl;
    }
  }
  if (!flag) cout << "NA" << endl;
  delete[] data;
  return true;
}
int main() {
  while (AOJ0100()) {
  }
  return 0;
}
