#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int f = 0;
    for (int i = 0; i < (int)n; ++i) {
      long long a, b, c;
      cin >> a >> b >> c;
      if (b * c >= 1000000) {
        if (f == 0) f = 1;
        cout << a << endl;
      }
    }
    if (f == 0) cout << "NA" << endl;
  }
}
