#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4020;
int i, p, q;
bool isfind = false;
map<int, long long> total;
int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0) return 0;
    for (int k = 0; k < n; k++) {
      cin >> i >> p >> q;
      total[i] += p * q;
    }
    for (map<int, long long>::iterator i = total.begin(); i != total.end();
         ++i) {
      if (i->second >= 1000000) {
        isfind = true;
        cout << i->first << endl;
      }
    }
    if (!isfind) cout << "NA" << endl;
    total.clear();
    isfind = false;
  }
  return 0;
}
