#include <bits/stdc++.h>
using namespace std;
typedef struct result {
  int nam;
  int mon;
  int cont;
  int sum;
} P;
int main() {
  P a[4000];
  int n, nacount;
  while (1) {
    cin >> n;
    nacount = 0;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> a[i].nam >> a[i].mon >> a[i].cont;
      a[i].sum = a[i].mon * a[i].cont;
    }
    for (int i = 0; i < n; i++) {
      for (int j = n - 1; j > i; j--) {
        if (a[i].nam == a[j].nam) {
          a[i].sum += a[j].sum;
          a[j].sum = 0;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (a[i].sum >= 1000000) {
        cout << a[i].nam << endl;
        nacount++;
      }
    }
    if (nacount == 0) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
