#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
void preview(T a, T b) {
  for (T it = a; it != b; ++it) cerr << *it << " ";
  cerr << endl;
}
const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;
int main() {
  for (int N; cin >> N, N;) {
    vector<int> shine(4001, 0);
    queue<int> idx;
    for (int i = 0; i < (int)N; ++i) {
      int num, a, b;
      cin >> num >> a >> b;
      if (shine[num] == 0) {
        shine[num] = a * b;
        idx.push(num);
      } else {
        shine[num] += a * b;
      }
    }
    bool f = false;
    while (!idx.empty()) {
      int t = idx.front();
      idx.pop();
      if (shine[t] >= 1000000) {
        cout << t << endl;
        f = true;
      }
    }
    if (!f) cout << "NA" << endl;
  }
  return 0;
}
