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<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		map<ll,ll>in;
		rep(i,n){
			ll a,b,c;
			cin>>a>>b>>c;
			in[a]+=b*c;
		}
		bool h=false;
		for(map<ll,ll>::iterator it=in.begin();it!=in.end();it++){
			int d=it->first;
			if(in[d]>=1e6){
				h=true;
				cout<<d<<endl;
			}
		}
		if(!h)cout<<"NA"<<endl;
	}
}

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

using namespace std;

int main() {

	int n;

	while(cin >> n) {
		if(!n) {
			break;
		}
		deque<int> x;
		for(int i=0; i<n; i++) {
			int num, v, q;
			cin >> num >> v >> q;
			if(v*q>=1000000) {
				int f=0;
				for(int j=0; j<x.size(); j++) {
					if(x[j]==num) {
						f=1;
						break;
					}
				}
				if(!f) {
					x.push_back(num);
				}
			}
		}

		if(x.empty()) {
			cout << "NA" << endl;
		}
		else {
			for(int i=0; i<x.size(); i++) {
				cout << x[i] << endl;
			}
		}
		
	}

	return 0;

}

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

int main()
{
	int n;

	while (cin >> n, n){
		int e[5000] = {0}, p, q, a;
		bool out = false;
		for (int i = 0; i < n; i++){
			cin >> a >> p >> q;
			e[a] += p * q;
		}
		for (int i = 0; i < 4001; i++){
			if (e[i] >= 1000000){
			 cout << i << endl;
			 out = true;
			}
		}
		if (out == false) cout << "NA" << endl;
	}
	return (0);
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
using namespace std;

typedef pair<int, int> P;

int main()
{
	int n, num, val, sale, c;
	P data[4000];
	int flag[4001];
	bool na;
	while(1){
		na = true;
		memset(flag, 0, sizeof(int)*4001);
		c = 1;

		cin >> n;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			cin >> num >> val >> sale;
			if(!flag[num]){
				flag[num] = c;
				data[c].first = num, data[c].second = val * sale;
				c++;
			}else data[flag[num]].second += val * sale;
		}

		for(int i=1; i<c; i++){
			if(data[i].second >= 1000000){
				na = false;
				cout << data[i].first << endl;
			}
		}
		if(na) cout << "NA" << endl;
	}
	return 0;
}

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

int main() {

	while(true) {

		int n;
		cin >> n;
		if ( n == 0 ) break;

		int score[4000] = {0};
		int num_max = 0;

		for ( int i = 0; i < n; i++ ) {

			int input_number;
			int tanka;
			int kazu;
			cin >> input_number >> tanka >> kazu;

			score[input_number] += tanka * kazu;
			num_max = max( num_max,input_number );

		}

		bool f = true;
		for ( int i = 0; i <= num_max; i++ ) {
			if ( score[i] >= 1000000 ) {
				cout << i << endl;
				f = false;
			}
		}

		if ( f ) cout << "NA" << endl;

	}

	return 0;
}

C++: #include<stdio.h>
#include<string.h>


int main(void){

	int i,n;
	char *p;
	char a[1002];
	scanf("%d\n",&n);
	for(i = 0;i < n;i++){
        fgets(a,sizeof(a),stdin);
        while((p = strstr(a,"hoshino"))!=NULL){
            p[6] = 'a';
        }
                printf("%s",a);

    }


return 0;
}

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

int main()
{
	int n, i;
	bool f;
	long long int a, b, c;
	map<long long int, long long int> member;
	map<long long int, long long int>::iterator it;
	while (cin>>n, n) {
		member.clear();
		for (i = 0; i < n; i++) {
			cin>>a>>b>>c;
			member[a] += b*c;
		}
		f = true;
		for (it = member.begin(); it != member.end(); it++) {
			if ((*it).second >= 1000000) {
				cout<<(*it).first<<endl;
				f = false;
			}
		}
		if (f) cout<<"NA"<<endl;
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll sums[4000];
bool used[4000];
int main()
{
	int n;
	while(cin>>n,n) 
	{
		vector<int> order;
		bool f=false;
		int num;
		int a,b;
		fill(sums,sums+4000,0);
		fill(used,used+4000,0);
		for(int i = 0; i < n; ++i)
		{
			cin>>num>>a>>b;
			sums[num-1]+=a*b;
			order.push_back(num-1);
		}
		for(int i = 0; i < order.size(); ++i)
		{
			if(!used[order[i]]&&sums[order[i]]>=1000000)
			{
				cout<<order[i]+1<<endl;
				f=true;
				used[order[i]]=true;
			}
		}
		if(!f) cout<<"NA"<<endl;
	}
  return 0;
}

C++: /*
	0100:Sale Result
*/
#include	<iostream>
#include	<map>

using namespace std;

int main(void) {
	int n;
	while(1) {
		bool isOK = false;
		map<int, long> MP;
		
		cin >> n;
		
		if(n == 0) { break; }
		
		for(int i = 0; i < n; i++) {
			int n, p, c;
			cin >> n >> p >> c;
			MP[n] += p * c;
		}
		for(map<int, long>::iterator it = MP.begin(); it != MP.end(); it++) {
			if(it->second >= 1000000) {
				cout << it->first << endl;
				isOK = true;
			}
		}
		if(isOK == false) {
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int main(){
	int n,a,b,c,flag;
	map<int, long long int> m;
	while (cin >> n, n){
		m.clear();
		flag = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b >> c;
			m[a] += b * c;
		}
		map<int, long long int>::iterator it = m.begin();
		while (it != m.end()){
			if ((*it).second >= 1000000){
				flag = 1;
				cout << (*it).first << endl;
			}
			it++;
		}
		if (!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string.h>
#include <queue>

using namespace std;

int N, M;

int main() {
	long long  goal = 1000000;

	for (; cin >> N;) {
		if (!N) break;
		long long  v[4000];
		queue<int> que;
		memset(v, 0, sizeof(v));
		for (int i = 0; i < N; i++) {
			long long  e, p, q;
			cin >> e >> p >> q;
			que.push(e);
			v[e - 1] += p*q;
		}
		bool flag = false;
		while(!que.empty()){
			if (v[que.front()] >= goal) {
				flag = true;
				v[que.front()] = 0;
				cout << que.front + 1 << endl;
			}
			que.pop();
		}
		if (!flag) cout << "NA" << endl;
	}

	return 0;
}

C++: #include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int id,cost,amount,n;
    while(cin >> n,n){
        map<int,long long> emps;
        vector<int> ids;
        bool exist = false;
        for(int i=0;i<n;i++){
            cin >> id >> cost >> amount;
            if(emps.find(id)!=emps.end()){
                emps[id]+=cost*amount;
            }else{
                emps[id]=cost*amount;
                ids.push_back(id);
            }
        }
        sort (ids.begin(),ids.end());
        for(int i=0;i<ids.size();i++){
            if(emps.at(ids[i])>=1000000){
                cout << ids[i] << endl;
                exist=true;
            }
        }
        if(!exist) cout << "NA" << endl;

    }
    return 0;
}