#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int e[5000] = {0}, p, q, a;
    bool out = false;
    for (int i = 0; i < n; i++) {
      cin >> a >> p >> q;
      e[a] += p * q;
    }
    for (int i = 1; i <= 4000; i++) {
      if (e[i] >= 1000000) {
        cout << i << endl;
        out = true;
      }
    }
    if (out == false) cout << "NA" << endl;
  }
  return (0);
}
