#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n != 0) {
    vector<pair<int, int> > ta;
    ta.clear();
    for (int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      bool f = 0;
      int index = 0;
      for (int j = 0; j < ta.size(); j++)
        if (ta[j].first == a) f = 1, index = j;
      if (f == 0)
        ta.push_back(pair<int, int>(a, b * c));
      else
        ta[index].second += b * c;
    }
    bool f = 0;
    for (int i = 0; i < ta.size(); i++) {
      if (ta[i].second >= 1000000) {
        cout << ta[i].first << endl;
        ;
        f = 1;
      }
    }
    if (!f) cout << "NA" << endl;
  }
  return 0;
}
