#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c;
  while (cin >> n, n) {
    vector<int> V;
    map<int, long long> M;
    while (n--) {
      cin >> a >> b >> c;
      if (M[a] == 0) V.push_back(a);
      M[a] += b * c;
    }
    int cnt = 0;
    sort(V.begin(), V.end());
    for (int i = 0; i < V.size(); i++) {
      if (M[V[i]] >= 1000000) {
        cnt++;
        cout << V[i] << endl;
      }
    }
    if (cnt == 0) cout << "NA" << endl;
  }
  return 0;
}
