#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    vector<int> ord;
    map<int, int> total;
    int m, x, y;
    for (int loopCount = 1; loopCount <= (n); loopCount++) {
      cin >> m >> x >> y;
      if (!(find(ord.begin(), ord.end(), (m)) != (ord).end())) ord.push_back(m);
      total[m] += x * y;
    }
    bool f = true;
    for (__typeof((ord).begin()) it = (ord).begin(); it != (ord).end(); it++)
      if (total[*it] >= 1000000) {
        f = false;
        cout << *it << endl;
      }
    if (f) cout << "NA" << endl;
  }
  return 0;
}
