#include <bits/stdc++.h>
using namespace std;
int main() {
  string str = "";
  while (getline(cin, str)) {
    int n;
    stringstream ssn(str);
    ssn >> n;
    if (n == 0) {
      break;
    }
    map<int, long long> res;
    int i;
    for (i = 0; i < n; ++i) {
      getline(cin, str);
      int id, p, q;
      stringstream ss(str);
      ss >> id >> p >> q;
      long long sum = (long long)(p * q);
      res[id] += sum;
    }
    map<int, long long>::iterator it = res.begin();
    map<int, long long> R;
    for (; it != res.end(); ++it) {
      int id = (*it).first;
      long long sum = (*it).second;
      if (sum >= 1000000LL) {
        R[id] = sum;
      }
    }
    if (R.empty()) {
      cout << "NA" << endl;
    } else {
      map<int, long long>::iterator itr = R.begin();
      for (; itr != R.end(); ++itr) {
        cout << (*itr).first << endl;
      }
    }
  }
  return 0;
}
