#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  while (1) {
    bool isOK = false;
    map<int, long long> MP;
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      int n, p, c;
      cin >> n >> p >> c;
      MP[n] += p * c;
    }
    for (map<int, long long>::iterator it = MP.begin(); it != MP.end(); it++) {
      if (it->second >= 1000000) {
        cout << it->first << endl;
        isOK = true;
      }
    }
    if (isOK == false) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
