#include <bits/stdc++.h>
using namespace std;
int main(void) {
  map<int, long long> m;
  int n;
  int no, amount, price;
  while (cin >> n) {
    bool exist = false;
    if (!n) break;
    for (int i = 0; i < n; i++) {
      cin >> no >> amount >> price;
      m[no] += amount * price;
    }
    map<int, long long>::iterator it = m.begin();
    while (it != m.end()) {
      if ((*it).second >= 1e+6) {
        cout << (*it).first << endl;
        exist = true;
      }
      ++it;
    }
    if (!exist) cout << "NA" << endl;
    m.clear();
  }
}
