#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (1) {
    long long record[4000] = {};
    int cnt = 0;
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      int id;
      long long p;
      long long q;
      cin >> id >> p >> q;
      record[id] += p * q;
    }
    for (int i = 0; i < 4000; i++) {
      if (record[i] >= 1000000) {
        cout << i << endl;
        cnt++;
      }
    }
    if (cnt == 0) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
