#include <bits/stdc++.h>
using namespace std;
long long int nums[10000];
int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < 10000; i++) {
      nums[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      int e, p, q;
      cin >> e >> p >> q;
      nums[e] += p * q;
    }
    bool check = false;
    for (int i = 0; i <= 4000; i++) {
      if (nums[i] >= 1000000) {
        cout << i << endl;
        check = true;
      }
    }
    if (!check) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
