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