#include <bits/stdc++.h>
using namespace std;
unsigned long long data[4001];
vector<int> V;
void print() {
  vector<int> M;
  for (int i = 0; i < 4001; i++)
    if (data[i] >= 1000000) M.push_back(i);
  if (M.size()) {
    for (int i = 0; i < V.size(); i++)
      if (binary_search(M.begin(), M.end(), V[i])) cout << V[i] << endl;
  } else
    cout << "NA" << endl;
}
int main() {
  unsigned long long in;
  while (cin >> in && in) {
    V.clear();
    fill(data, data + 4001, 0);
    for (int i = 0; i < in; i++) {
      unsigned long long num, p, q;
      cin >> num >> p >> q;
      if (!binary_search(V.begin(), V.end(), num)) V.push_back(num);
      if (data[num] < 1000000) data[num] += p * q;
    }
    print();
  }
  return 0;
}
