#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = 3.14159265359;
int main() {
  int n;
  while (cin >> n, n) {
    vector<long long int> sales(4001);
    int num;
    long long int tanka, kazu;
    for (int i = 0; i < n; i++) {
      cin >> num >> tanka >> kazu;
      sales[num] += tanka * kazu;
    }
    bool NA = true;
    for (int i = 1; i <= 4000; i++) {
      if (sales[i] >= 1000000) {
        cout << i << endl;
        NA = false;
      }
    }
    if (NA) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
