#include <bits/stdc++.h>
using namespace std;
int main() {
  int data[3][4000], n, i, f;
  while (1) {
    cin >> n;
    if (n == 0) break;
    for (i = 0; i < n; i++) cin >> data[0][i] >> data[1][i] >> data[2][i];
    for (i = 0, f = 0; i < n; i++)
      if (data[1][i] * data[2][i] > 999999) cout << data[0][i] << "\n", f = 1;
    if (f == 0)
      cout << "NA"
           << "\n";
  }
}
