#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  while (cin >> n, n != 0) {
    long long memo[4000] = {0};
    for (long long i = 0; i < n; ++i) {
      long long a, b, c;
      cin >> a >> b >> c;
      memo[a] += (b * c);
    }
    long long ans = 0;
    for (long long i = 0; i < 4000; ++i) {
      if (memo[i] >= 1000000) {
        cout << i << endl;
        ans++;
      }
    }
    if (ans == 0) cout << "NA" << endl;
  }
  return 0;
}
