#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    map<int, unsigned long long> tmp;
    for (int i = (int)(0); i < (int)(n); i++) {
      int no, price, num;
      cin >> no >> price >> num;
      tmp[no] += price * num;
    }
    vector<int> res;
    for (__typeof((tmp).begin()) it = tmp.begin(); it != tmp.end(); ++it) {
      if (1000000 <= (*it).second) {
        res.push_back((*it).first);
      }
    }
    if (res.size() == 0) {
      cout << "NA" << endl;
    } else {
      for (int &no : res) {
        cout << no << endl;
      }
    }
  }
  return 0;
}
