#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  long long c;
  map<int, long> data;
  vector<int> id;
  while (true) {
    id.clear();
    data.clear();
    cin >> n;
    if (!n) break;
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      c *= b;
      if (data.find(a) == data.end()) {
        data.insert(make_pair(a, c));
        id.push_back(a);
      } else {
        data[a] += c;
      }
    }
    bool empty = true;
    for (int i = 0; i < id.size(); i++) {
      if (data[id[i]] >= 1000000) {
        cout << id[i] << endl;
        empty = false;
      }
    }
    if (empty) cout << "NA" << endl;
  }
  return 0;
}
