#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, id, a, b;
  while (cin >> n, n) {
    map<int, int> m;
    vector<int> v;
    vector<int>::iterator p;
    for (i = 0; i < n; i++) {
      cin >> id >> a >> b;
      m[id] += a * b;
      for (p = v.begin(); p != v.end(); p++) {
        if (*p == id) break;
      }
      if (p == v.end()) v.push_back(id);
    }
    bool f = false;
    for (vector<int>::iterator it = v.begin(); it != v.end(); it++) {
      if (m[(*it)] >= 1000000) {
        cout << *it << endl;
        f = true;
      }
    }
    if (!f) cout << "NA" << endl;
  }
  return 0;
}
