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++: /*
	AOJ_0100: Sale Result
*/
#include	<iostream>
#include	<vector>
#include	<utility>

using namespace std;

typedef unsigned long long ull;

class employee {
private:
	int number;
	ull proceed;
public:
	employee() {
		number = 1;
		proceed = 0;
	}
	employee(int _n, ull _p) {
		number = _n;
		proceed = _p;
	}
	void addProceed(ull in_prcd) {
		if (proceed < 1000000) { proceed += in_prcd; }
	}
	bool isSatisfy(void) {
		return (proceed >= 1000000 ? true : false);
	}
	int showNumber(void) {
		return number;
	}
};

int main(void) {
	vector<employee> Emps;
	int n, member, price, count;
	ull buf_prcd;
	bool isNothing, isNotHit;

	while (1) {
		isNothing = true;

		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> member >> price >> count;
			buf_prcd = price * count;
			isNotHit = true;

			vector<employee>::iterator it = Emps.begin();
			while (it != Emps.end()) {
				if (it->showNumber() == member) {
					isNotHit = false;
					it->addProceed(buf_prcd);
					break;
				}
				it++;
			}
			if (isNotHit) {
				Emps.push_back( employee(member, buf_prcd) );
			}
		}

		isNotHit = true;
		vector<employee>::iterator it = Emps.begin();
		while (it != Emps.end()) {
			if (it->isSatisfy() == true) {
				isNotHit = false;
				cout << it->showNumber() << endl;
			}
			it++;
		}
		if (isNotHit) {
			cout << "NA" << endl;
		}
		Emps.clear();
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) (s).begin(),(s).end()

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

#define INF 999999
#define MAX_V 999

using namespace std;

int main(){
	int n, id, val, num;
	vector<int> ans;
	vector<int> com(4000);
	while(cin>>n,n){
		ans.clear();
		rep(i,4000)	com[i]=0;
		rep(i,n){
			cin>>id>>val>>num;
			if(!com[id-1])	ans.push_back(id);
			com[id-1]+=val*num;
		}
		bool flag=true;
		rep(i,ans.size()){
			if(com[ans[i]-1]>=1000000){
				cout<<ans[i]<<endl;
				flag=false;
			}
		}
		if(flag){
			cout<<"NA"<<endl;
		}
	}
	
	return 0;
	
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
	int n,id,i,k,f,a,b,da[4001],jun[4001],ch[4001];
	while (cin >> n) {
		if (n==0) break;
		memset(da,0,sizeof(da));
		memset(ch,0,sizeof(ch));
		k=0;
		for (i=0;i<n;i++) {
			cin >> id >> a >> b;
			da[id]+=a*b;
			if (ch[id]==0 && da[id]>999999) { ch[id]=1; jun[k++]=id;} 
			}
		f=0;
		for (i=0;i<k;i++) if (da[jun[i]]>=1000000) { cout << jun[i] << endl; f=1; }
		if (f==0) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


ll n;

int main(){
	while(cin>>n,n!=0){
		ll id[4005]={0};
		int a[8000]={0};
		
		int cou;
		rep(i,n){
			ll t1,t2,t3;
			cin>>t1>>t2>>t3;
			a[i]=t1;
			//if(id[t1]>0){
				id[t1]+=t2*t3;
			//}
			/*
			else{
				id[t1]=t2*t3;
			}
			*/
			cou=i;
		}
		bool f=true;
		rep(i,cou+1){
			if(id[a[i]]>=1000000){
				cout<<a[i]<<endl;
				id[a[i]]=0;
				f=false;
			}
		}
		if(f) cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <stdio.h>

struct employees
{
	int i;
	int p;
	int q;
};

int main(void)
{
	int n, m, x, y, z;
	struct employees number[4000] = {0};

	scanf("%d", &m);
	n = 0;
	while (scanf("%d %d %d", &x, &y, &z) != EOF)
	{
		if (x == 0)
			break;
		if (x <= 4000 && y <= 1000000 && z <= 100000)
		{
			number[n].i = x;
			number[n].p = y;
			number[n].q = z;
			n++;
		}
		if (m <= n)
			break;
	}
	for (n = 0, m = 0; n < 4000; n++)
	{
		if (number[n].i == 0)
			break;
		if (number[n].q * number[n].p >= 1000000)
		{
			printf("%d\n", number[n].i);
			m++;
		}
	}
	if (m == 0)
			printf("NA\n");

	return 0;
}

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

int main() {
	int n;
	while(std::cin >> n){
		if(!n){
			return 0;
		}
		std::vector<std::pair<int, long long> > sales;
		while(n--){
			int id, unit, num;
			std::cin >> id >> unit >> num;
			int i = 0;
			for(; i < sales.size(); i++){
				if(sales.at(i).first == id){
					sales.at(i).second += (long long)unit * num;
					break;
				}
			}
			if(i == sales.size()){
				std::pair<int, long long> worker;
				worker.first = id;
				worker.second = (long long)unit * num;
				sales.push_back(worker);
			}
		}
		bool found = false;
		for(int i = 0; i < sales.size(); i++){
			if(sales.at(i).second >= 1000000){
				found = true;
				std::cout << sales.at(i).first << std::endl;
			}
		}
		if(!found){
			std::cout << "NA" << std::endl;
		}
	}
	return 0;
}

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

struct Saler
{
	int Number;
	int Saled;
};

int main(){
	struct Saler* sl;
	int n, a, b, c, i;
	bool isFound;
	
loop:
	scanf("%d", &n);		// データ個数
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * n);
	memset(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d", &a, &b, &c);
		for(i = 0; i < n; i++)
		{
			if(sl[i].Number == 0)
			{
				sl[i].Number = a;
				sl[i].Saled = b * c;
				break;
			}
			else if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		if(sl[j].Saled > 1000000)
		{
			cout << sl[j].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
	free(sl);
	goto loop;
end_scope:
    return 0;
}

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

int main(){
	int n, s, m, No;
	bool flag;
	
	while( cin >> n, n){
		flag = true;
		
		for(int i=0 ; i<n ; i++){
			cin >> No >> s >> m;
			if( s*m >= 1000000){
				flag = false;
				cout << No << endl;
			}
		}
		if(flag){
			cout << "NA" << endl;
		}
	}
	
	return 0;
}

C++: #include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,long long> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int n,cnt,b,s,f;
	long long t,c;
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		cnt=0;
		vector<pii> v;
		rep(i,n){
			scanf("%d%d%d",&b,&t,&c);
			s=v.size();
			f=1;
			rep(i,s)if(v[i].first==b){
				v[i].second += t*c;
				f=0;
			}
			if(f)v.push_back(pii(b,t*c));
		}
		s=v.size();
		rep(i,s)if(v[i].second >= 1000000){
			printf("%d\n",v[i].first);
			cnt++;
		}
		if(cnt==0)puts("NA");
	}
	return 0;
}