#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s, m, No;
  int person[4001];
  bool flag;
  while (cin >> n, n) {
    flag = true;
    for (int i = 0; i < 4001; i++) {
      person[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      cin >> No >> s >> m;
      person[No] += s * m;
    }
    for (int i = 0; i < 4001; i++) {
      if (person[i] >= 1000000) {
        flag = false;
        cout << i << endl;
      }
    }
    if (flag) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
