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 <cstdio>
#include <iostream>
#include <vector>
#include <utility>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
	ll n;
	while(scanf("%d\n", &n), n){
		vector<pair<ll, ll> > v;
		rep(i,n) {
			ll x, y, z;
			cin >> x >> y >> z;
			bool f = false;
			for(ll j = 0; j < v.size(); ++j) {
				if(v[j].first == x) {
					v[j].second += (ll) y * z;
					f = true;
					break;
				}
			}
			if(!f) {
				v.push_back(make_pair(x, (ll)(y * z)));
			}
		}
		bool flag = false;
		for(ll j = 0; j < v.size(); ++j) {
			if(v[j].second >= 1000000) {
				flag = true;
				cout << v[j].first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 

using namespace std;

int main()
{
	int n,f,b;
	long long c,d;

	while(1){
		f=1;int k=0;
		int a[4000][2]={0};
		cin>>n; if(n==0) return 0;

		for(int i=0;i<n;i++){
			cin>>b>>c>>d;
			for(int j=0;j<k;j++){
				if(a[j][0]==b && a[j][1]>0){ a[j][1]+=c*d; f=0;}
			}
			if(f){
				a[k][0]=b; a[k++][1]=c*d;
			}
		}

		f=0;
		for(int i=0;i<k;i++){
			if(a[i][1]>=1000000) {cout<<a[i][0]<<endl; f=1;}
		}
		if(f) cout<<"NA"<<endl;
	}
}

C++: #include<stdio.h>

int main(void) {
	long long int a, b, count = 1, number = 0, syain[4010], tanka[4010], suuryou[4010], score[4010] = {}, noruma = 1000000, sens = 0;
	while (count) {
		sens = 0;
		long long int score[4010] = {};
		scanf("%d", &count);
		for (size_t i = 0; i < count; i++)
		{
			scanf("%lld %lld %lld", &syain[number], &tanka[number], &suuryou[number]);
			score[syain[number]] += tanka[number] * suuryou[number];
			if (score[syain[number]] >= noruma)
			{
				printf("%lld\n", syain[number]);
				sens++;
			}
			number++;
		}
		if (sens == 0 && count != 0)
		{
			printf("NA\n");
		}
	}
	return 0;
}

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

int main() {
	int n;
	while(std::cin >> n){
		if(!n){
			return 0;
		}
		std::map<int, long long> sales;
		while(n--){
			int id, unit, num;
			std::cin >> id >> unit >> num;
			sales[id] += (long long)unit * num;
		}
		map<int, long long>::iterator it;
		bool found = false;
		for(it = sales.begin(); it != sales.end(); it++){
			if(it->second >= 1000000){
				found = true;
				std::cout << it->first << std::endl;
			}
		}
		if(!found){
			std::cout << "NA" << std::endl;
		}
	}
	return 0;
}

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

struct R{
int num;
long long int su;
int k;
};

int main(){

int N,M;

while(1){

struct R n[4001];
cin>>N;if(N==0)break;
for(int i=0;i<=4000;i++)
	n[i].su=0;

for(int i=1;i<=N;i++){
	int r,q,nu;
	cin>>nu;n[nu].num=nu;cin>>r>>q;
	if(n[nu].su==0){n[nu].k=i;}
	n[nu].su+=r*q;
	
}/*
for(int i=0;i<N;i++)
	for(int j=i+1;j<N;j++)
	{if(n[i].num==n[j].num){n[i].su+=n[j].su;n[j].su=0;}
	}*/
bool f=false;
for(int i=0;i<N;i++)
for(int j=0;j<4001;j++)
	if(n[j].k==i&&n[j].su>=1000000)
	{cout<<n[j].num<<endl;f=true;}

	if(f==false)cout<<"NA"<<endl;
}
return 0;
}

	

/*


string str;int s=0;
for(int iii=0;iii<M;iii++){
	cin>>str;
	for(int i=0;i<N;i++){bool f=true;
		for(int j=0;j<8;j++)
			if((n[i].y[j]!=str[j])&&n[i].y[j]!='*'){f=false;}//cout<<n[i].y[j]<<"#"<<str[j]<<endl;}
		if(f==true)s+=n[i].C;
	}

}

cout<<s<<endl;



}
return 0;
}*/

C++: #include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{

    int n=1,num,tanka,suryo;
    bool na=true;
    while(true){
        cin>>n;
        if(n==0){
            return 0;
        }
        for(int i=0;i<n;i++){
            cin>>num>>tanka>>suryo;
            if(tanka*suryo>=1000000){cout<<num<<endl;na=false;}
        }
        if(na)cout<<"NA"<<endl;
        na=true;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long int lint;
typedef long long int llint;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl "\n"

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  
  while (cin >> n, n){
    llint p, q;
    llint e[1010] = {0}, res[4010] = {0};
    bool judge = false;
    REP(i, n){
      cin >> e[i] >> p >> q;
      res[e[i]] += p * q;
    }
    sort(e, e + n);
    REP(i, n){
      if (res[e[i]] >= 1000000 && e[i] != e[i + 1]){
        cout << e[i] << endl;
        judge = true;
      }
    }
    if (!judge) cout << "NA" << endl;
  }
}

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

int main(){
	int n, id;
	long long int a, b;

	while( cin >> n , n ){
		map<int,long long int> employees;
		vector<int> vc;
		bool flag = true;
		
		for(int i=0 ; i<n ; ++i ){
			cin >> id >> a >> b;
			if( !employees[id] ) vc.push_back( id );
			employees[id] += a * b;	
		}
		for(int i=0 ; i<vc.size() ; ++i ){
			if( employees[ vc[i] ] >= 1000000 ){
				cout << vc[i] << endl;
				flag = false;
			}
		}
		if( flag ){
			cout << "NA" << endl;
		}
	}
}

C++: #include<iostream>
#include<cstring>
using namespace std;
long long int sales[4010];

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0)break;
    
        memset(sales,0,sizeof(sales));
        int num,tanka,kazu;

        for(int i=0;i<n;i++)
        {
            cin>>num>>tanka>>kazu;
            sales[num] += tanka*kazu;
        }
        int na = 0;
        for(int i=1;i<4001;i++)
        {
            if(sales[i]>=1000000)
            {
                na = 1;
                cout<< i<<endl;
            }
    
        }
        if(na==0)cout<< "NA"<<endl;
    }
    return 0;
}

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

typedef struct shain{
	int id;
	int uriage;
	struct shain *next;
}shine;

shine *makeNewNode(int id,int tanka,int uriage){
	shine *newNode;
	newNode=(shine *)malloc(sizeof(shine));
	
	newNode->id=id;
	newNode->uriage=uriage*tanka;
	newNode->next=NULL;
	return (newNode);
}

int main(){
	int count=0,counter;
	while(1){
		scanf("%d",&counter);
		if(counter==0){
			break;
		}
		count=0;
		shine *newNode;
		shine *nowNode;
		shine *firstNode=NULL;
		while(counter>count){
			int a,b,c;
			scanf("%d %d %d",&a,&b,&c);
			newNode=makeNewNode(a,b,c);
			if(firstNode==NULL){
				firstNode=newNode;
				nowNode=newNode;
			}else{
				nowNode=firstNode;
				while(nowNode->id!=newNode->id&&nowNode->next!=NULL){
					nowNode=nowNode->next;
				}
				
				if(nowNode->id==newNode->id){
					nowNode->uriage+=newNode->uriage;
				}else{
					nowNode->next=newNode;
				}
			}
			count++;
		}
		nowNode=firstNode;
		int flag=1;
		while(nowNode!=NULL){
			if(nowNode->uriage>=1000000){
				printf("%d\n",nowNode->id);
				flag=0;
			}
			nowNode=nowNode->next;
		}
		if(flag){
			printf("NA\n");
		}
	}
	return 0;
}