#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c;
  while (cin >> n && n) {
    vector<pair<long long, long long> > v;
    while (n--) {
      cin >> a >> b >> c;
      bool f = true;
      for (int i = 0; i < v.size(); i++) {
        if (v[i].first == a) {
          f = false;
          v[i].second += b * c;
        }
      }
      if (f) {
        v.push_back(pair<long long, long long>(a, b * c));
      }
    }
    bool f = true;
    for (int i = 0; i < v.size(); i++) {
      if (v[i].second >= 1000000) {
        f = false;
        cout << v[i].first << endl;
      }
    }
    if (f) cout << "NA" << endl;
  }
}
