#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, id, val, num;
  vector<int> ans;
  vector<int> com(4000);
  while (cin >> n, n) {
    ans.clear();
    for (int i = (0); i < (4000); ++i) com[i] = 0;
    for (int i = (0); i < (n); ++i) {
      cin >> id >> val >> num;
      if (!com[id - 1]) ans.push_back(id);
      com[id - 1] += val * num;
    }
    bool flag = true;
    for (int i = (0); i < (ans.size()); ++i) {
      if (com[ans[i] - 1] >= 1000000) {
        cout << ans[i] << endl;
        flag = false;
      }
    }
    if (flag) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
