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