#include <bits/stdc++.h>
using namespace std;
int n;
void solve() {
  bool ok = false;
  for (int i = 0; i < n; i++) {
    int num, a, b;
    cin >> num >> a >> b;
    if (a * b >= 1000000) {
      cout << num << endl;
      ok = true;
    }
  }
  if (!ok) cout << "NA" << endl;
}
int main() {
  while (cin >> n) {
    if (n == 0) break;
    solve();
  }
  return 0;
}
