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