#include <bits/stdc++.h>
using namespace std;
int main() {
  long sale, kosuu, n, bangou;
  while (cin >> n, n) {
    int syain[4001] = {0};
    while (n--) {
      cin >> bangou >> sale >> kosuu;
      syain[bangou] += kosuu * sale;
    }
    int f = 0;
    for (int i = 1; i <= 4000; i++) {
      if (syain[i] >= 1000000) {
        cout << i << endl;
        f = 1;
      }
    }
    if (f == 0) cout << "NA" << endl;
  }
}
