Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

C++: //include
//------------------------------------------
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n)  FOR(i,0,n)

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
//-------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

long long data[4001];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(1) {
        cin >> n;
        if (!n) break;
        memset(data, 0, sizeof(data));
        REP(i, n) {
            int e;
            long long p, q;
            cin  >> e >> p >> q;
            data[e] += p * q;
        }
        int c = 0;
        FOR(i, 1, 4001) {
            if (data[i] >= 1000000) {
                cout << i << endl;
                ++c;
            }
        }

        if (!c) cout << "NA" << endl;
    }

    return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

int main()
{
  while(1){
    int n;
    cin>>n;
    if(n == 0){
      break;
    }

    vector<pair<int,int>> data;
    for(int i = 0;i < n;++i){
      int num,sa,ko;
      cin>>num;
      cin>>sa;
      cin>>ko;

      int sum = sa * ko;
      data.push_back(make_pair(num,sum));
    }

    int check = 0;
    for(pair<int,int> e : data){
      if(e.second >= 1000000){
        check = 1;
        cout<<e.first<<endl;
      }
    }
    if(check == 0){
      cout<<"NA"<<endl;
    }
  }

  return 0;
}

C++: #include<iostream>
using namespace std;

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
long int shineU[SHINE_MAX];	//?£??????????

int num,tanka,suryo;
int i;

int main(){
	while(1){
	 cin>>shineN;
	 if(shineN==0){break;}
	 for(i=0;i<SHINE_MAX;i++){shineU[i]=0;}
	 for(i=0;i<shineN;i++){
	  cin>>num,tanka,suryo;
	  shineU[num]+=tanka*suryo;
	 }
	 //??¨?????????????????¨
	 eliteN=0;
	 for(i=0;i<SHINE_MAX && eliteN<shineN;i++){
	  if(ELITE<=shineU[i]){
	   cout<<i<<endl;
	   eliteN++;
	  }
	 }
	 if(eliteN==0){cout<<AHO<<endl;}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){

  int n, id, val, num;
  int member[4000];

  while(cin >> n){

    if(!n) break;

    memset(member, 0, sizeof(member));

    for(int i = 0; i < n; ++i){
      cin >> id >> val >> num;
      member[id - 1] += val * num;
    }

    bool flag = false;

    for(int i = 0; i < 4000; ++i){
      if(member[i] >= 1000000){
        cout << i + 1 << endl;
        flag = true;
      }
    }

    if(!flag) cout << "NA" << endl;

  }

}

C++: #include<iostream>
#include<map>
using namespace std;

int main(){
	int n,num,mn,nm,mon;
	while(cin >> n,n){
		int c=0,sc[4001],cn=0,cc=0;
		map<int,int> maps;
		for(int i=0;i<n;i++){
			int cnt=0,j=0;
			cin >> num >> mn >> nm;
			mon = mn*nm;
			maps[num] += mon;
			for(;j<c;j++){
				if(sc[j]==num)cn++;
			}
			if(cn==0||j==0){
				sc[c] = num;
				c++;
				//cout << sc[c] << endl;
			}
		}
		for(int i=0;i<c;i++){
			if(maps[sc[i]]>=1000000){
				cout << sc[i] << endl;
				cc++;
			}
		}
		if(cc==0) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <map>

using namespace std;

int main(){
	int n;
	while(cin >> n){
		if(n == 0){
			break;
		}
		map<int, int> m;
		for(int i = 0; i < n; i++){
			int id, price, amount;
			cin >> id >> price >> amount;
			m[id] += price * amount;
		}
		bool applicable = false;
		for(map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++){
			if(itr->second >= 1000000){
				applicable = true;
				cout << itr->first << endl;
			}
		}
		if(!applicable){
			cout << "NA" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;

struct data{
    int id;
    long long int sales;
    data(int a, int b) : id(a), sales(b) {}
};

int main(){
    int n;
    while( cin >> n, n ){
        vector< data > ls;
        for(int i = 0; i < n; i++){
            int a, b, c;
            cin >> a >> b >> c;
            vector<data>::iterator it = ls.begin();
            for(; it!=ls.end(); it++){
                if( it->id == a ){
                    it->sales += b*c;
                    break;
                }
            }
            if( it == ls.end() ){
                ls.push_back( data(a, b*c) );
            }
        }
        bool exs = false;
        for(vector<data>::iterator it = ls.begin(); it != ls.end(); it++){
            if( it->sales >= 1000000 ){
                cout << it->id << endl;
                exs = true;
            }
        }
        if( !exs ){
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

long long int n,a,b,c;



int main(){
    
        
    while(cin >> n){
        if(n==0)break;
        
        long long int ans[4001]={0};
        
        bool flag=true;
        for(int i=0; i<n; i++){
            cin>>a>>b>>c;
            if(ans[a]<1000000)ans[a]+=b*c;
        }
        
        for(int i=1; i<=4000; i++){
            if(ans[i]>=1000000){
                cout<<i<<endl;
                flag=false;
            }
        }
        
        if(flag)cout<<"NA"<<endl;
    }
            
}

C++: #include<stdio.h>
long long int t[4000];
int k[4000];
bool sub[4000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<4000;i++){
			t[i]=0;
			k[i]=0;
			sub[i]=false;
		}
		int o=0;
		for(int i=0;i<a;i++){
			int b,c,d;
			
			scanf("%d%d%d",&b,&c,&d);
			t[b-1]+=(long long)c*(long long)d;
			if(!sub[b-1]){
				k[o++]=b-1;
				sub[b-1]=true;
			}
		}
		bool ok=false;
		for(int i=0;i<o;i++){
			if(t[k[i]]>=1000000LL){
				printf("%d\n",k[i]+1);
				ok=true;
			}
		}
		if(!ok)printf("NA\n");
	}
}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        map<int,long long int>M;
        while(n--){
            int a,b,c;
            cin>>a>>b>>c;

            M[a]=(long long)b*c;;
        }

        bool flag=true;
        for(map<int,long long int>::iterator ite=M.begin();ite!=M.end();ite++){
            if(ite->second>=1000000){
                cout<<ite->first<<endl;
                flag=false;
            }
        }
        if(flag)cout<<"NA"<<endl;
    }
    return 0;
}