#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 24;
const int N = 4001;
const int B = (int)1e6;
int main(void) {
  for (int n, f; cin >> n, n; cout << (f ? "" : "NA\n")) {
    vector<long long> in(N);
    vector<int> p;
    while (f = n--) {
      int id, v, m;
      cin >> id >> v >> m;
      if ((in[id] += v * m) >= B) in[id] = B;
      if (find(p.begin(), p.end(), id) == p.end()) p.push_back(id);
    }
    for (__typeof((p).begin()) it = (p).begin(); it != (p).end(); it++)
      if (f = in[*it] == B) cout << *it << endl;
  }
  return 0;
}
