#include <bits/stdc++.h>
using namespace std;
const int sales = 1000000;
int main() {
  int n;
  while (scanf("%d", &n), n) {
    bool flag[4000] = {false};
    queue<int> employee_n;
    for (int i = 0; i < n; ++i) {
      int number, a, b;
      scanf("%d %d %d", &number, &a, &b);
      if (sales > a * b || flag[number - 1]) continue;
      flag[number - 1] = true;
      employee_n.push(number);
    }
    while (!employee_n.empty()) {
      printf("%d\n", employee_n.front());
      employee_n.pop();
    }
    if (employee_n.empty()) puts("NA");
  }
  return 0;
}
