#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  while (scanf("%d", &n)) {
    if (n == 0) break;
    map<int, long long int> m;
    map<int, long long int>::iterator it;
    for (int i = 0; i < n; i++) {
      int x;
      long long int p, q;
      scanf("%d%lld%lld", &x, &p, &q);
      if (m.find(x) == m.end())
        m[x] = p * q;
      else
        m[x] += p * q;
    }
    bool ok = true;
    for (it = m.begin(); it != m.end(); it++) {
      if (it->second >= 1000000) {
        ok = false;
        cout << it->first << endl;
      }
    }
    if (ok) cout << "NA" << endl;
  }
}
