#include <iostream>
using namespace std;

int main()
{
  int N;
  for (;;) {
    cin >> N;
    if (N == 0) {
      break;
    }
    int n[4000];
    for (int i = 0; i < 4000; i++) n[i] = 0;
    for (int i = 0; i < N; i++) {
      int ID, p, q;
      cin >> ID >> p >> q;
      n[ID] += p*q;
    }

    int j = 1;
    for (int i = 0; i < 4000; i++) {
      if (n[i] >= 1000000) {
        cout << i << endl;
        j = 0;
      }
    }
    if (j) {
      cout << "NA" << endl;
    }
  }

  return 0;
}