#include <bits/stdc++.h>
using namespace std;
const int MAX = 101;
template <class T, class U>
void convert(T &t, U &u) {
  stringstream ss;
  ss << t;
  ss >> u;
}
int main() {
  int n;
  while (cin >> n && n != 0) {
    map<int, long long> ans;
    vector<int> idx;
    int id, price, num;
    for (int i = 0; i < n; i++) {
      cin >> id >> price >> num;
      if (!ans.count(id)) idx.push_back(id);
      ans[id] += price * num;
    }
    vector<int> ans_id;
    for (int i = 0; i < idx.size(); i++) {
      if (ans[idx[i]] >= 1000000) ans_id.push_back(idx[i]);
    }
    if (ans_id.size() == 0) {
      cout << "NA" << endl;
    } else {
      for (int i = 0; i < ans_id.size(); i++) {
        cout << ans_id[i] << endl;
      }
    }
  }
  return 0;
}
