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 <stdio.h>
#define ull unsigned long long int
typedef struct{
	int o;
	ull val;
}pair;

ull hoge(pair crew[],ull t,ull s,int num){
	crew[num].val+=t*s;
	return crew[num].val;
}

int main(){
	pair crew[4000];
	ull t,s;
	int i,n,num,N=1000000;
	while(1){
		for(i=0;i<4000;i++) crew[i].val=0,crew[i].o=-1;
		i=0;
		scanf("%d",&n);
		if(!n) break;
		while(n--){
			scanf("%d%llu%llu",&num,&t,&s);
			if(N<=hoge(crew,t,s,num)) if(crew[num].o<0) crew[num].o=i++;
		}
		for(int j=0;j<i;j++){
			for(int k=0;k<4000;k++) if(j==crew[k].o) printf("%d\n",k);
		}
		if(!i) printf("NA\n");
	}
	return 0;
}

C++: #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;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define ll long long

int main(){
  int i,j,k,n;
  int id;
  ll a, b;

  while(scanf("%d",&n)){
    bool f = false;
    if(n == 0) break;

    while(n--){
      scanf("%d %lld %lld",&id,&a,&b);
      if(a * b >= 1000000){
        printf("%d\n",id);
        f = true;
      }
    }
    if(f) puts("NA");
  }

  return 0;
}

C++: #include <stdio.h>

int main(int argc, char *argv){
	int n, f;
	int ID, price, num;
	while(1){
		scanf("%d ", &n);
		if(!n) break;
		f=0;
		while(n--){
			scanf("%d %d %d ", &ID, &price, &num);
			if(1000000 <= price * num){
				printf("%d\n", ID);
				f = 1;
			}
		}
	}
	if(!f) printf("NA\n");
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;
 
int main(){
	int N,A[100000],B,C;
	while(cin>>N,N){
		int cnt[4001]={};
		for(int i=0;i<N;i++){
			cin>>A[i]>>B>>C;
			cnt[A[i]] += B*C;
		}
		bool NAflag=true,used[4001]={};
		for(int i=0;i<N;i++){
			if(cnt[A[i]]>=1000000 && used[A[i]]==false){
				printf("\t%d\n",A[i]); used[A[i]] = true; NAflag = false;
			}
		}
		if(NAflag==true) puts("\tNA");
	}
    return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct salary{
	int no;
	long long sell;
};

int main() {
	
	int n;
	while(cin>>n,n){
		vector<salary> vs;
		vector<int> vi;
		REP(i, n){
			int no, sell_n, value;
			cin >> no >> sell_n >> value;
			bool b = false;
			REP(j, vs.size()){
				if (vs[j].no == no){
					b = true;
					vs[j].sell += sell_n*value;
					
				}
			}
			if (!b)vs.push_back({ no, sell_n*value });
			REP(j, vs.size()){
				if (vs[j].sell >= 1000000){
					if (find(vi.begin(), vi.end(), vs[j].no) == vi.end())vi.push_back(vs[j].no);
				}
			}
		}
		REP(i, vi.size()){
			cout << vi[i]<< endl;
		}
		if (vi.size()==0)cout << "NA"<< endl;
	}
}

C++: #include<iostream>
using namespace std;
int ans[4000];

int main(){
	int N;
	long int e, p, q;
	int x;
	while (1){
		x = 0;
		cin >> N;
		if (N == 0){ break; }
		while (N){
			cin >> e >> p >> q;
			cout << N<<x << endl;
			if (p*q >= 1000000){
				ans[x] = e;
				x++;
			}
			N--;
		}
			for (int i = 0; i < N; i++)
			{
				if (i == 0 && ans[i] == 0)cout << "NA" << endl;
				if (ans[i] == 0){ break; }
				cout << ans[i] << endl;
			}
	}
	return 0;
}

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

        vector<int>V;
        map<int,long long>M;
        while(n--){
            cin>>a>>b>>c;
            if(M[a]==0)V.push_back(a);
            M[a]+=b*c;

        }

        bool flag=true;
        sort(V.begin(),V.end());
        for(int i=0;i<V.size();i++){
            if(M[V[i]]>=1000000){
                flag=false;
                cout<<V[i]<<endl;
            }
        }
        if(flag)cout<<"NA"<<endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <map>
#include <vector>

using namespace std;

int main(){
	int n;
	map<int,long> list;
	vector<int> people;
	while(scanf("%d",&n) != EOF && n){
		int a,b,c;
		list.clear();
		people.clear();
		for(int i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&c);
			people.push_back(a);
			list[a] += b * c;
		}
		vector<int>::iterator it;
		bool flag = true;
		for(it = people.begin();it != people.end();it++){
			
			if(list[*it] >= 1000000){
				printf("%d\n",*it);
				flag = false;
			}
			
			list[*it] = 0;
		}
		if(flag){
			printf("NA\n");
		}
	}
}

C++: #include<iostream>
#include<queue>
#include<map>
using namespace std;
main(){
  long long a,b,c,n,f;
  while(cin>>n,n){
		map<int,long long> m;
		queue<int> v;
		f=1;
    for(;n;n--){
			cin>>a>>b>>c;
      if(!m[a])v.push(a);
      m[a] += b*c;
    }
    
    while(v.size())
			if(m[v.front()]>999999)f=0,cout<<v.pop()<<endl;
    if(f)cout<<"NA"<<endl;
  }
}