#include <bits/stdc++.h>
const double PI = acos(-1);
const double EPS = 1e-10;
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    map<long long, long long> in;
    for (int i = 0; i < n; i++) {
      long long a, b, c;
      cin >> a >> b >> c;
      in[a] += b * c;
    }
    bool h = false;
    for (map<long long, long long>::iterator it = in.begin(); it != in.end();
         it++) {
      int d = it->first;
      if (in[d] >= 1e6) {
        h = true;
        cout << d << endl;
      }
    }
    if (!h) cout << "NA" << endl;
  }
}
