#include <bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  
  while (cin >> n, n){
    long long s[4000] = {0}, p, q;
    int e;

    for (int i = 0; i < n; i++){
      cin >> e >> p >> q;
      s[e - 1] += (p * q);
    }
    bool f = false;
    for (int i = 0; i < 4000; i++){
      if (s[i] >= 1000000){
        cout << i + 1 << endl;
        f = true;
      }
    }

    if (!f){
      cout << "NA" << endl;
    }

  }

  return 0;
}