#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    map<int, long long int> m;
    vector<int> v;
    for (int i = 0; i < n; i++) {
      int place = -1;
      int p, q, r;
      cin >> p >> q >> r;
      if (m[p] == 0) v.push_back(p);
      m[p] += q * r;
    }
    bool isExist = false;
    for (int i = 0; i < v.size(); i++) {
      if (1000000 <= m[v[i]]) {
        isExist = true;
        cout << v[i] << endl;
      }
    }
    if (!isExist) cout << "NA" << endl;
  }
}
