#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, No, unit, number;
  while (cin >> n, n) {
    map<int, int> employees;
    vector<int> vc;
    bool flag = false;
    for (int i = 1; i <= 4000; ++i) {
      employees[i] = 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> No >> unit >> number;
      if (count(vc.begin(), vc.end(), No) == 0) {
        vc.push_back(No);
      }
      employees[No] += unit * number;
    }
    for (int i = 0; i < vc.size(); ++i) {
      if (employees[vc[i]] >= 1000000) {
        cout << vc[i] << endl;
        flag = true;
      }
    }
    if (flag == false) {
      cout << "NA" << endl;
    }
  }
}
