#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int shine[4000 + 1];
  bool shinef[4000 + 1];
  bool na;
  int n, a, b, c;
  while (cin >> n, n) {
    na = true;
    for (int i = 0; i < 4000; i++) {
      shine[i] = 0;
      shinef[i] = false;
    }
    while (n--) {
      cin >> a >> b >> c;
      shine[a] += c * b;
      if (shine[a] >= 1000000 && shinef[a] == false) {
        cout << a << endl;
        shinef[a] = true;
        na = false;
      }
    }
    if (na) cout << "NA" << endl;
  }
  return 0;
}
