#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n && n != 0) {
    map<int, long long int> staff;
    queue<int> Queue;
    bool cnt = false;
    for (size_t i = 0; i < n; i++) {
      int num;
      long long b, c;
      cin >> num >> b >> c;
      staff[num] += (long long int)(b * c);
    }
    for (map<int, long long int>::iterator itr = staff.begin();
         itr != staff.end(); itr++) {
      if (itr->second >= 1000000) Queue.push(itr->first);
    }
    if (Queue.size() == 0) {
      cout << "NA" << endl;
    } else {
      while (Queue.size() > 0) {
        cout << Queue.front() << endl;
        Queue.pop();
      }
    }
  }
  return 0;
}
