#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, id[1000], array[1000][1000], i, j, count;
  while (1) {
    count = 0;
    cin >> n;
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      cin >> id[i];
      for (j = 0; j < 2; j++) {
        cin >> array[i][j];
      }
    }
    for (i = 0; i < n; i++) {
      if (array[i][0] * array[i][1] >= 1000000) {
        cout << id[i] << endl;
        count++;
      }
    }
    if (count == 0) cout << "NA" << endl;
  }
}
