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