#include <bits/stdc++.h>
using namespace std;
int main() {
  bool tf = 0;
  int n, e, p, q;
  while (cin >> n) {
    if (n == 0) {
      break;
    }
    int r[4001] = {0};
    tf = 0;
    for (int i = 0; i < n; i++) {
      cin >> e >> p >> q;
      r[e] += p * q;
    }
    for (int i = 1; i <= 4000; i++) {
      if (r[i] >= 1000000) {
        cout << i << endl;
        tf = 1;
      }
    }
    if (tf != 1) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
