#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    long long int total[4000];
    for (int i = 0; i < 4000; i++) total[i] = 0;
    for (int i = 0; i < n; i++) {
      int a;
      long long int b, c;
      cin >> a >> b >> c;
      total[a - 1] += b * c;
    }
    bool NA = true;
    for (int i = 0; i < 4000; i++) {
      if (total[i] >= 1000000) {
        cout << i + 1 << endl;
        NA = false;
      }
    }
    if (NA) cout << "NA" << endl;
  }
  return 0;
}
