#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n && n) {
    long long int arr[1000000 + 5] = {0};
    bool flag = false;
    for (int i = 0; i < n; i++) {
      int id, p, q;
      cin >> id >> p >> q;
      arr[id] += (p * q);
    }
    for (int i = 1; i <= 1000000; i++) {
      if (arr[i] >= 1000000) {
        cout << i << endl;
        flag = true;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
  return 0;
}
