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 <vector>
#include <algorithm>
int main(){
  int n,sn,p,c;
  std::vector<int> v;
  while(std::cin>>n){
    if(!n)return 0;
    for(;n;n--){
      std::cin>>sn>>p>>c;
      std::vector<int>::iterator it=std::find(v.begin(),v.end(),sn);
      if(p*c>=1000000){
        if(it==v.end()){
          v.push_back(sn);
        }
      }
    }
    if(v.empty())std::cout<<"NA"<<std::endl;
    else{
    std::vector<int>::iterator it = v.begin();
    while(it!=v.end()){
      std::cout<<*it<<std::endl;
      it++;
    }
    v.clear();
    }
  }
}

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,B,C;
	while(cin>>N,N){
		int cnt[4001]={};
		for(int i=0;i<N;i++){
			cin>>A>>B>>C;
			cnt[A] += B*C;
		}
		bool NAflag=true;
		for(int i=1;i<=4000;i++){
			if(cnt[i]>=1000000){
				NAflag = false;
				printf("%d\n",i);
			}
		}
		if(NAflag==true) puts("NA");
	}
    return 0;
}

C++: #include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>
#include<iomanip>
#include<queue>


using namespace std;

void Solution()
{
   	int n;
    
    int number, perPrice, amount;
    
    bool isUsed;
    //long long valueCheck[4000];
    vector<long long> valueCheck(4000, 0);
    queue<int> que;
    
    while(true)
    {
        isUsed = false;
        
        cin>>n;
        
        if (n == 0)
        {
            break;
        }
        
        while(n--)
        {
            cin>>number>>perPrice>>amount;
            
            valueCheck[number] += perPrice * amount;
            que.push(number);
        }
        
        while (!que.empty())
        {
            if (valueCheck[que.front()] >= 1000000)
            {
                cout<<que.front()<<endl;
                isUsed = true;
            }
            
            valueCheck[que.front()] = 0;
            que.pop();
        }
        
        if (!isUsed)
        {
            cout<<"NA"<<endl;
        }
        
//            if ( valueCheck >= 1000000)
//            {
//                cout<<number<<endl;
//            }
//            else
//            {
//                count++;
//            }
//            
//            if (count == m)
//            {
//                cout<<"NA"<<endl;
//            }
        
    }
}

int main()
{
    Solution();
    return 0;
}

C++: #include<cstdio>

int main(){
int a,i,fl;
unsigned long int b,c;
while(1){
scanf("%d",&i);
fl=0;
for(int j=0;j<i;j++){


 scanf("%d",&a);
 if(a==0){
 return 0;
}
 scanf("%ld",&b);
 scanf("%ld",&c);
if(a*c>=1000000) {
 fl=1;
 printf("%d\n",a);
}
if(fl==false) pritnf("NA\n");
}
}
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  bool kai;
  int t[5000]={0};
  long long sum[5000]={0};
  bool NA=true;
  while(cin>>n,n){
    NA=true;
    kai=false;
    for(int i=0;i<5000;i++){
      t[i]=0; sum[i]=0;
    }
    int a,b,c;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      for(int j=0;j<5000;j++){
	if(t[j]==a)break;
	if(t[j]==0){t[j]=a;break;}
      }
      
      if(sum[a]<=1000000)sum[a]+=b*c;
    }
    for(int i=0;i<5000;i++){
      if(sum[t[i]]>=1000000){
	if(kai){cout<<endl; }cout<<t[i]; kai=true;  NA=false;
      }
    }
    if(NA)cout<<"NA"<<endl;
  }
}

C++: #include <stdio.h>

int main(void)
{
	int staff[1000];
	int n;
	int price[1000];
	int num[1000];
	int i;
	int flag[1000];
	int a_flag;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		a_flag = 0;
		for (i = 0; i < n; i++){
			flag[i] = 0;
			scanf("%d %d %d", &staff[i], &price[i], &num[i]);
			if (price[i] * num[i] >= 1000000){
				flag[i] = 1;
				a_flag++;
			}
		}
		
		if (a_flag){
			for (i = 0; i < n; i++){
				if(flag[i]){
					printf("%d\n", staff[i]);
				}
			}
		}
		else {
			printf("NA\n");
		}
	}
	
	return (0);
}

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

const long long BORDER = 1000000;

using namespace std;

int main() {
  bool f;
  int i, j, n, number;
  long long price, amount;
  while(cin >> n) {
    if (n == 0) break;
    
    map<int, long long> m;
    map<int, long long>::iterator it;

    for (i = 0; i < n; i++) {
      cin >> number >> price >> amount;
      it = m.find(number);
      if (it != m.end())
        it->second += price * amount;
      else
        m.insert(pair<int, long long>(number, price * amount));
    }
    for (it = m.begin(), f = false; it != m.end(); it++) {
      if (it->second >= BORDER) {
        f = true;
        cout << it->first << endl;
      }
    }
    if (!f) cout << "NA" << endl;
  }

  return 0;
}

C++: #include <cstdio>
#include <queue>
using namespace std;

const int sales = 1000000;

int main()
{
	int n;
	while(scanf("%d",&n),n) {
		bool flag[4000]={flalse};
		queue<int> employee_n;
		for(int i=0;i<n;++i) {
			int number,a,b;
			scanf("%d %d %d",&number,&a,&b);
			if(sales>a*b||flag[number-1]) continue;
			flag[number-1]=true;
			employee_n.push(number);
		}
		while(!employee_n.empty()){
			printf("%d\n",employee_n.front());
			employee_n.pop();
		}
		if(employee_n.empty()) puts("NA");
	}	
	return 0;
}

C++: #include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/

int main(){
    int n, e, p, q;
    while(cin >> n, n != 0) {
        ll m[4001] = {};
        int a[1000] = {};
        REP(i, n){
            cin >> e >> p >> q;
            m[e] += p * q;
            a[i] = e;
        }
        bool f = true;
        REP(i, n){
            if(m[a[i]] >= 1000000){
                cout << a[i] << '\n';
                m[a[i]] = 0;
                f = false;
            }
        }
        if(f) cout << "NA\n";
    }
    return 0;
}

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

using namespace std;
#define mp make_pair
int main(){
  int n;
  string a;
  long long b,c;
  map<string,long> data;
  vector<string> id;
  while(true){
    id.clear();
    data.clear();
    cin>>n;
    if(!n)
      break;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      c*=b;
      if(data.find(a)==data.end()){
	data.insert(mp(a,c));
	id.push_back(a);
      }
      else{
	data[a]+=c;
      }
    }
    bool empty = true;
    for(int i=0;i<id.size();i++){
      if(data[id[i]]>=1000000){
	cout<<id[i]<<endl;
	empty = false;
      }
    }
    if (empty)
      cout<<"NA"<<endl;

  }
  return 0;
}

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

typedef long long ll;

int n;
ll p[4000];
std::vector<int> ord;

int main()
{
	while( std::cin >> n, n )
	{
		memset( p, 0, sizeof( p ) );
		ord.clear();

		for( ll a, b, c, i = 0; i < n; ++i )
		{
			std::cin >> a >> b >> c;
			if( p[a-1] == 0 )ord.push_back( a - 1 );	
			p[a-1] += b * c;
		}
		bool fl = false;
		for( int i = 0; i != ord.size(); ++i )
			if( p[ord[i]] >= 1000000 )
				std::cout << ord[i] + 1 << std::endl, fl = true;

		if( !fl )
			std::cout << "NA" << std::endl;
	}
	return 0;
}