#include <bits/stdc++.h>
using namespace std;
int main() {
  long size, id, price, quantity;
  bool noone = true;
  while (1) {
    cin >> size;
    if (size == 0) break;
    for (int i = 0; i < size; i++) {
      cin >> id >> price >> quantity;
      if (price * quantity >= 1000000) {
        cout << id << endl;
        noone = false;
      }
    }
    if (noone) cout << "NA" << endl;
    noone = true;
  }
}
