
//ツ単ツ渉δづ可嘉ーツつッツづ篠つ「ツつ「ツつセツつッツつセツつェ, ツ板?湘」ツ額ツつェintツづ可偲サツづ慊づァツづ按つ「ツ嘉つ能ツ青ォツつェツつ?づゥツづ個づ?陳債暗督つオツづ按つッツづェツづ篠づ按づァツづ按つ「
//ツ姪「ツ妥ィツ閉カツづ可渉堕つゥツづェツづ?つ「ツづゥツ「100ツ鳴?* 10ツ鳴慊」ツづ個湘ーツ個渉づ?づ? intツづ可偲サツづ慊づァツづ按つ「
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

int main(){
  int n;
  ll sum[4002], num[4002];

  while(cin >> n, n){
    //ツ催?渉? ツ全ツ暗オツ板?湘」ツづ?
    fill(sum, sum + 4002, 0);

    //ツ全ツ暗オツづ慊つセツ禿シツ療債つウツづェツづ?つ「ツづ按つ「
    fill(num, num + 4002, -1);

    //ツ渉?氾板づ可湘ョツ陛アツづーツ禿シツ療?
    for(int i = 0; i < n; i++){
      ll m, a, b;
      cin >> m >> a >> b;

      //ツ板?湘」ツづーツ堕ォツつオツつアツづ?
      sum[m] += a * b;

      //ツ渉可づ淞づ?禿シツ療債つウツづェツつスツ偲青暗オツ氾板債?づ按づァツづ? ツ可スツ氾板姪堋づ可禿シツ療債つウツづェツつスツつゥツ記ツ可ッツつオツづ?つィツつュ
      if(num[m] == -1){
        num[m] = i;
      }
    }

    //ツ板?湘」ツつェ100ツ鳴慊暗按湘」ツづ個人ツづーツ療アツ仰督つキツづゥ
    //ツつアツづ個づ?つォ, ツ可スツ氾板姪堋づ可禿シツ療債つウツづェツつスツ人ツづ?つ?づゥツつゥツづ?つ「ツつ、ツ湘ョツ陛アツづ?暗ェツ渉渉づ英ush
    vector<P> ans;

    for(int i = 0; i < 4002; i++){
      if(1000000 <= sum[i]){
        ans.push_back(P(num[i], i));
      }
    }

    //ツ禿シツ療債渉?づ可陛?づ堕妥鳴つヲ
    sort(ans.begin(), ans.end());

    //ツ督堋つヲツ出ツ療?
    for(int i = 0; i < ans.size(); i++){
      cout << ans[i].second << endl;
    }

    //1ツ人ツづ?該ツ督鳴偲陳つェツつ「ツづ按つッツづェツづ晒A
    if(ans.size() == 0){
      cout << "NA\n";
    }
  }
}
#include <iostream>
#include <vector>
#include <utility>
#include <map>

using namespace std;

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector< pair<int, long long> > members;
        for (int i = 0; i < n; i++) {
            pair<int, long long> member;
            int id;
            long long cost, count;
            cin >> id >> cost >> count;
            bool exist = false;
            for (int i = 0; i < members.size(); i++) {
                if (members[i].first == id) {
                    members[i].second += cost * count;
                    exist = true;
                }
            }
            if (!exist) {
                member.first = id;
                member.second = cost * count;
                members.push_back(member);
            }
        }
        bool exist = false;
        for (vector< pair<int, long long> >::iterator m_i = members.begin();
                m_i != members.end(); m_i++) {
            if (m_i->second >= 1000000) {
                cout << m_i->first << endl;
                exist = true;
            }
        }
        if (!exist) {
            cout << "NA" << endl;
        }
    }
    return 0;
}
               

            