#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s[4000], i, bangou, tanka, suuryou;
  while (cin >> n) {
    int c = 0;
    if (!n) break;
    for (i = 0; i < 4000; i++) s[i] = 0;
    for (i = 0; i < n; i++) {
      cin >> bangou >> tanka >> suuryou;
      s[bangou] += tanka * suuryou;
    }
    for (i = 0; i < 4000; i++) {
      if (s[i] >= 1000000) {
        cout << i << endl;
        c++;
      }
    }
    if (!c) cout << "NA" << endl;
  }
  return 0;
}
