#include <bits/stdc++.h>
using namespace std;
bool employee[4000] = {false};
const int sales = 1000000;
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    if (n == 0) {
      break;
    }
    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 || employee[number - 1]) continue;
      employee[number - 1] = true;
      employee_n.push(number);
    }
    if (employee_n.empty())
      puts("NA");
    else {
      while (!employee_n.empty()) {
        printf("%d\n", employee_n.front());
        employee_n.pop();
      }
    }
  }
  return 0;
}
