#include <bits/stdc++.h>
using namespace std;
bool isLeap(int y);
long long gcd(long long a, long long b);
long long lcm(long long a, long long b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);
int main() {
  int n, id, price, num;
  map<int, long long> tbl;
  vector<int> vi;
  while (cin >> n, n) {
    tbl.clear();
    vi.clear();
    for (int i = 0; i < n; i++) {
      cin >> id >> price >> num;
      if (tbl.find(id) == tbl.end()) vi.push_back(id);
      tbl[id] += price * num;
    }
    bool flag = false;
    for (int i = 0; i < vi.size(); i++) {
      if (tbl[vi[i]] >= 1000000) {
        cout << vi[i] << endl;
        flag = true;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
  return 0;
}
bool isLeap(int y) {
  return y % 400 == 0 ? true : y % 100 == 0 ? false : y % 4 == 0 ? true : false;
}
long long gcd(long long a, long long b) { return (b > 0) ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void trace(int A[], int N) {
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}
double distanceAB(double xa, double ya, double xb, double yb) {
  return sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));
}
