#include <bits/stdc++.h>
using namespace std;
int main(void) {
  while (1) {
    long long int n, tmp[3], cnt = 0, flg = 0;
    vector<long long int> number;
    vector<long long int> sales;
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      flg = 0;
      cin >> tmp[0] >> tmp[1] >> tmp[2];
      for (int j = 0; j < number.size(); j++) {
        if (number.at(j) == tmp[0]) {
          sales.at(j) += tmp[1] * tmp[2];
          flg = 1;
          break;
        }
      }
      if (flg == 1) break;
      number.push_back(tmp[0]);
      sales.push_back(tmp[1] * tmp[2]);
    }
    for (int i = 0; i < number.size(); i++) {
      if (sales.at(i) >= 1000000) {
        cout << number.at(i) << endl;
        cnt++;
      }
    }
    if (cnt == 0) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
