#include <bits/stdc++.h>
using namespace std;
bool p[4001];
int main() {
  int i, n, id, price, num, cnt = 0;
  ;
  while (cin >> n) {
    if (n == 0) break;
    for (i = 0; i < 4001; i++) {
      p[i] = false;
    }
    for (i = 0; i < n; i++) {
      cin >> id >> price >> num;
      if (price * num >= 1000000) {
        p[id] = true;
        cnt++;
      }
    }
    for (i = 0; i < 4001; i++) {
      if (p[i] == true) {
        cout << i << endl;
      }
    }
    if (cnt == 0) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
