#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0) break;
    long long p[4001];
    for (int i = 0; i < 4001; i++) {
      p[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      int b;
      long long t, s;
      cin >> b >> t >> s;
      p[b] += t * s;
    }
    int count = 0;
    for (int i = 1; i < 4001; i++) {
      if (p[i] >= 1000000) {
        cout << (i) << endl;
        ;
        count++;
      }
    }
    if (count == 0) {
      cout << ("NA") << endl;
      ;
    }
  }
  return 0;
}
