#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, bg, tn, su;
  while (cin >> n) {
    if (n == 0 || cin.eof()) break;
    map<int, int> sk;
    for (int i = 0; i < n; i++) {
      cin >> bg >> tn >> su;
      sk[bg] += tn * su;
    }
    int cnt = 0;
    map<int, int>::iterator it = sk.begin();
    while (it != sk.end()) {
      if ((*it).second >= 1000000) {
        cout << (*it).first << endl;
        cnt++;
      }
      it++;
    }
    if (cnt == 0) cout << "NA" << endl;
  }
  return 0;
}
