#include <bits/stdc++.h>
int main() {
  int n, num[4001];
  while (std::cin >> n) {
    int count = 0;
    memset(num, 0, sizeof(num));
    if (n == 0) break;
    for (int a, b, c, i = 0; i < n; i++) {
      std::cin >> a >> b >> c;
      num[a] += b * c;
    }
    for (int i = 0; i < 4001; i++) {
      if (num[i] >= 1000000) count++, std::cout << i << std::endl;
    }
    if (count == 0) std::cout << "NA" << std::endl;
  }
  return 0;
}
