#include <bits/stdc++.h>
using namespace std;
long long int sales[4010];
int main() {
  int n;
  while (cin >> n) {
    vector<int> shains;
    if (n == 0) break;
    memset(sales, 0, sizeof(sales));
    int num, tanka, kazu;
    for (int i = 0; i < n; i++) {
      cin >> num >> tanka >> kazu;
      sales[num] += tanka * kazu;
      int f = 0;
      for (vector<int>::iterator it = shains.begin(); it != shains.end();
           ++it) {
        if (*it == num) {
          f = 1;
          break;
        }
      }
      if (f == 0) shains.push_back(num);
    }
    int na = 0;
    for (vector<int>::iterator it = shains.begin(); it != shains.end(); ++it) {
      if (sales[*it] >= 1000000) {
        cout << *it << endl;
        na = 1;
      }
    }
    if (na == 0) cout << "NA" << endl;
  }
  return 0;
}
