#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    map<int, long long> info;
    map<int, long long>::iterator it;
    for (int i = (0); i < (n); i++) {
      int a, b, c;
      cin >> a >> b >> c;
      info[a] += b * c;
    }
    bool c = true;
    for (it = info.begin(); it != info.end(); it++) {
      if (it->second >= 1000000) {
        cout << it->first << endl;
        c = false;
      }
    }
    if (c) cout << "NA" << endl;
  }
}
