#include <bits/stdc++.h>
using namespace std;
map<int, long long> mp;
vector<int> v;
int main() {
  int n;
  while (cin >> n && n) {
    mp.clear();
    for (int i = 0; i < n; i++) {
      int a;
      long long b, c;
      cin >> a >> b >> c;
      if (!mp[a]) v.push_back(a);
      mp[a] += b * c;
    }
    bool isExist = false;
    for (int i = 0; i < v.size(); i++) {
      if (mp[v[i]] >= 1000000) {
        isExist = true;
        cout << v[i] << endl;
      }
    }
    if (!isExist) cout << "NA" << endl;
  }
  return 0;
}
