#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n && n) {
    vector<int> v;
    map<int, int> m;
    int no, price, amount;
    int na = 1;
    for (int i = 0; i < n; i++) {
      cin >> no >> price >> amount;
      if (m.find(no) != m.end())
        m[no] += price * amount;
      else {
        m[no] = price * amount;
        v.push_back(no);
      }
    }
    vector<int>::iterator it = v.begin();
    while (it != v.end()) {
      if (m[*it] >= 1000000) {
        cout << *it << endl;
        na = 0;
      }
      it++;
    }
    if (na) cout << "NA" << endl;
  }
  return 0;
}
