#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n && n) {
    map<string, long long> data;
    vector<string> id;
    for (int i = (0); i < (int)(n); i++) {
      string a;
      long long b, c;
      cin >> a >> b >> c;
      long long t = b * c;
      if (data.count(a)) {
        data[a] = t;
        id.push_back(a);
      } else {
        data[a] += t;
      }
    }
    bool NA = true;
    for (int i = (0); i < (int)(id.size()); i++) {
      if (data[id[i]] >= 1000000) {
        cout << id[i] << endl;
        NA = false;
      }
    }
    if (NA) cout << "NA" << endl;
  }
}
