#include <bits/stdc++.h>
using namespace std;
int main() {
  bool f;
  long long int n, a, b, c, d[4001], i;
  while (cin >> n && n > 0) {
    memset(d, 0, sizeof(d));
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c;
      d[a] += b * c;
    }
    for (i = 1, f = 0; i <= 4000; i++) {
      if (d[i] >= 1000000) {
        cout << i << endl;
        f = 1;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
