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