#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, n;
  int price, qua;
  while (cin >> n, n) {
    int tof = 1;
    int staff_info[n];
    for (i = 0; i < n; i++) {
      cin >> staff_info[i] >> price >> qua;
      staff_info[i] = price > 1000000 && qua  ? staff_info[i]
                      : price * qua > 1000000 ? staff_info[i]
                                              : 0;
    }
    for (i = 0; i < n; i++) {
      if (staff_info[i]) {
        cout << staff_info[i] << endl;
        tof = false;
      }
    }
    if (tof) {
      cout << "NA\n";
    }
  }
}
