#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, n, no[4000], tanka[4000], num[4000];
  bool flg = false;
  while (1) {
    flg = false;
    cin >> n;
    if (n == 0) break;
    for (i = 0; i < n; i++) cin >> no[i] >> tanka[i] >> num[i];
    for (i = 0; i < n; i++) {
      if (tanka[i] * num[i] > 1000000) flg = true, cout << no[i] << endl;
    }
    if (flg == false) cout << "NA" << endl;
  }
  return 0;
}
