#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>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
long long snum[4001];
int main() {
  int N;
  vector<string> res;
  while (1) {
    cin >> N;
    if (N == 0) break;
    memset((snum), 0, sizeof(snum));
    for (int i = (0); i < (N); ++i) {
      long long num, tanka, suryo;
      cin >> num >> tanka >> suryo;
      snum[num] += tanka * suryo;
    }
    bool c = false;
    for (int i = (0); i < (4001); ++i) {
      if (snum[i] >= 1000000) {
        c = true;
        res.push_back(toString(i));
      }
    }
    if (!c) res.push_back("NA");
  }
  for (int i = (0); i < (int((res).size())); ++i) {
    cout << res[i] << endl;
  }
  return 0;
}
