#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, num, mon, cont, a[4001], nacount;
  while (scanf("%d", &n) != EOF) {
    if (n == 0) {
      break;
    }
    for (int i = 0; i < 4001; i++) {
      a[i] = 0;
    }
    nacount = 0;
    for (int i = 0; i < n; i++) {
      cin >> num >> mon >> cont;
      a[num] += mon * cont;
      if (a[num] >= 1000000) {
        cout << num << endl;
        nacount++;
      }
    }
    if (nacount == 0) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
