#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, n, value, count, number, f;
  while (cin >> n, n) {
    f = 0;
    for (i = 0; i < n; i++) {
      cin >> number >> value >> count;
      if (value * count >= 1000000LL) cout << number << endl, ++f;
    }
    if (!f) cout << "NA" << endl;
  }
  return 0;
}
