#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    map<int, int> com;
    bool f = false;
    while (n--) {
      int a, b, c;
      cin >> a >> b >> c;
      if (com[a] + b * c > 1000000) {
        com[a] = 1000000;
      } else {
        com[a] += b * c;
      }
    }
    map<int, int>::iterator m;
    for (m = com.begin(); m != com.end(); m++) {
      if ((m->second) >= 1000000) {
        cout << m->first << endl;
        f = true;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
