#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ban, tanka, kazu, i, j, x = {0};
  bool y = {false};
  for (j = 0; j < 50; j++) {
    cin >> n;
    if (n == 0) {
      break;
    }
    for (i = 0; i < n; i++) {
      cin >> ban >> tanka >> kazu;
      if (tanka * kazu >= 1000000) {
        cout << ban << endl;
        y = true;
        x += ban;
      }
    }
    if (y == false) {
      cout << "NA" << endl;
    }
    y = false;
  }
  return 0;
}
