#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    long long int tmp[4001] = {0};
    for (int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      tmp[a] += b * c;
    }
    int co = 0;
    for (int i = 0; i < 4001; i++) {
      if (tmp[i] >= 1000000) {
        co++;
        cout << i << endl;
      }
    }
    if (!co) cout << "NA" << endl;
  }
}
