#include <bits/stdc++.h>
using namespace std;
void Solution() {
  int n;
  int number, perPrice, amount;
  bool isUsed;
  vector<long long> valueCheck(4001, 0);
  queue<int> que;
  while (true) {
    isUsed = false;
    cin >> n;
    if (n == 0) {
      break;
    }
    while (n--) {
      cin >> number >> perPrice >> amount;
      valueCheck[number] += perPrice * amount;
      que.push(number);
    }
    while (!que.empty()) {
      if (valueCheck[que.front()] >= 1000000) {
        cout << que.front() << endl;
        isUsed = true;
      }
      valueCheck[que.front()] = 0;
      que.pop();
    }
    if (!isUsed) {
      cout << "NA" << endl;
    }
  }
}
int main() {
  Solution();
  return 0;
}
