#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, buf_n;
  bool flag;
  unsigned long long buf_t, buf_c, buf_p;
  map<int, unsigned long long> List;
  while (1) {
    cin >> n;
    if (n == 0) {
      break;
    }
    flag = true;
    List.clear();
    for (int i = 0; i < n; i++) {
      cin >> buf_n >> buf_p >> buf_c;
      buf_t = buf_p * buf_c;
      if (List.find(buf_n) == List.end()) {
        List[buf_n] = buf_t;
      } else {
        List[buf_n] += buf_t;
      }
    }
    map<int, unsigned long long>::iterator it = List.begin();
    while (it != List.end()) {
      if (it->second >= 1000000) {
        flag = false;
        cout << it->first << endl;
      }
      it++;
    }
    if (flag) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
