#include <bits/stdc++.h>
using namespace std;
const int lim = 1000000;
int main() {
  int n;
  long long en, price, qty, check[4001];
  queue<int> que;
  while (cin >> n && n) {
    if (n == 0) break;
    for (int i = 0; i < n; ++i) {
      cin >> en >> price >> qty;
      if (check[en] >= 0) {
        check[en] += price * qty;
      }
      if (check[en] >= lim) {
        que.push(en);
        check[en] = -1;
      }
    }
    if (que.empty()) {
      cout << "NA" << endl;
    } else {
      for (int i = 0, len = que.size(); i < len; ++i) {
        cout << que.front() << endl;
        que.pop();
      }
    }
  }
  return 0;
}
