#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int a, b, c;
    map<int, int> sale;
    bool f = true;
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      if (sale[a] + b * c > 1000000) {
        sale[a] = 1000000;
      } else {
        sale[a] += b * c;
      }
    }
    for (map<int, int>::iterator pos = sale.begin(); pos != sale.end(); pos++) {
      if (pos->second >= 1000000) {
        cout << pos->first << endl;
        f = false;
      }
    }
    if (f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
