#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n && n) {
    map<int, pair<int, int>> m;
    int c = 0;
    for (int i = (0); i < int(n); i++) {
      long long id, unit, num;
      cin >> id >> unit >> num;
      if (m.count(id) == 0) {
        m[id].first = c++;
      }
      m[id].second += unit * num;
    }
    vector<pair<int, int>> ans;
    for (auto& p : m) {
      if (p.second.second >= 1000000) {
        ans.push_back(make_pair(p.second.first, p.first));
      }
    }
    sort(ans.begin(), ans.end());
    if (ans.size()) {
      for (int i = (0); i < int(ans.size()); i++) {
        cout << ans[i].second << endl;
      }
    } else {
      cout << "NA" << endl;
    }
  }
}
