#include <bits/stdc++.h>
using namespace std;
void solve100(int n) {
  long officer[4001] = {0};
  long o, p, q;
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> o >> p >> q;
    officer[o] += p * q;
  }
  int cnt = 0;
  for (int(i) = 0; (i) < (4001); (i)++) {
    if (officer[i] >= 1000000) {
      cnt++;
      cout << i << endl;
    }
  }
  if (cnt == 0) cout << "NA" << endl;
}
int main() {
  int n;
  while (cin >> n, n) {
    solve100(n);
  }
  return 0;
}
