#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long p[4000];
  int count;
  while (cin >> n, n) {
    for (int i = 0; i < 4000; ++i) p[i] = 0;
    for (int i = 0; i < n; ++i) {
      long long wn, va, cn;
      cin >> wn >> va >> cn;
      p[wn - 1] += va * cn;
    }
    count = 0;
    for (int i = 0; i < 4000; ++i) {
      if (p[i] >= 1000000) {
        cout << i + 1 << endl;
        count++;
      }
    }
    if (!count) cout << "NA" << endl;
  }
}
