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