#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    long long int ma[4001] = {0};
    vector<long long int> ve;
    ve.clear();
    for (int k = 0; k < n; k++) {
      int a, b, c;
      cin >> a >> b >> c;
      if (ma[a] == 0) ve.push_back(a);
      ma[a] += b * c;
    }
    int f = 1;
    for (vector<long long int>::iterator it = ve.begin(); it != ve.end();
         it++) {
      if (ma[(*it)] >= 1000000) {
        cout << (*it) << endl;
        f = 0;
      }
    }
    if (f) cout << "NA" << endl;
  }
  return 0;
}
