#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int s[4000];
  bool ss[4000 + 1];
  int n;
  int in1, in2, in3;
  while (true) {
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < 4000; i++) {
      s[i] = 0;
    }
    for (int i = 0; i < 4000 + 1; i++) {
      ss[i] = false;
    }
    for (int i = 0; i < n; i++) {
      cin >> in1 >> in2 >> in3;
      s[in1] += in2 * in3;
      if (s[in1] >= 1000000) {
        ss[in1] = true;
        ss[4000] = true;
      }
    }
    if (!ss[4000]) {
      cout << "NA" << endl;
      continue;
    }
    for (int i = 0; i < 4000; i++) {
      if (ss[i]) {
        cout << i << endl;
      }
    }
  }
  return 0;
}
