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