#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, n;
  while (cin >> n, n) {
    int tof = 1;
    int num;
    long long price, qua;
    map<int, long long> staff;
    map<int, long long>::iterator itr;
    while (n-- > 0) {
      cin >> num >> price >> qua;
      staff[num] += price * qua;
    }
    for (itr = staff.begin(); itr != staff.end(); itr++) {
      if (itr->second >= 1000000) {
        cout << itr->first << endl;
        tof = 0;
      }
    }
    if (tof) cout << "NA" << endl;
  }
}
