#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, long long> table;
  int n;
  bool flug;
  while (cin >> n, n != 0) {
    flug = false;
    table.clear();
    for (int i = 1; i <= n; i++) {
      int id;
      int tanka;
      int number;
      cin >> id >> tanka >> number;
      table[id] += (tanka * number);
    }
    for (map<int, long long>::iterator itpair = table.begin();
         itpair != table.end(); itpair++) {
      if (itpair->second >= 1000000) {
        cout << itpair->first << endl;
        flug = true;
      }
    }
    if (flug != true) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
