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<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(4001, 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<bits/stdc++.h>
using namespace std;
#define int long long
const int N=4005,M=1000000;
signed main(void){
	int n;
	bool flag;
	int id[N],sum[N];
	map<int,int> Map; 
	ios::sync_with_stdio(false);
	while(cin>>n&&n){
		Map.clear();
		flag=true;
		memset(sum,0,sizeof(sum));
		for(int i=1,x,y;i<=n;i++){
			cin>>id[i]>>x>>y;
			if(!Map[id[i]])
				Map[id[i]]=i;
			sum[Map[id[i]]]+=x*y;
		}
		for(int i=1;i<=n;i++)
			if(sum[i]>=M){
				flag=false;
				cout<<id[i]<<endl;
			}
		if(flag)
			cout<<"NA"<<endl;
	}
}

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

using namespace std;

int main()
{
	int number, value, value_num;
	int num_data;
	int data[4000];
	
 /**Input**/
	while (true){
		bool NA = false;
		for (int ix = 0; ix != 4000; ++ix)
			data[ix] = 0;

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

		for (int ix = 0; ix != num_data; ++ix){
			cin >> number;
			cin >> value >> value_num;
			data[number] += value * value_num;
		}

		for (int ix = 0; ix != 4000; ++ix){
			if (data[ix] >= 1000000){
				cout << ix << endl;
				NA = true;
			}
		}
		if (!NA)
			cout << "NA" << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
int main(){
  int n;
  std::map<int,long long> m;
  std::vector<int> v;
  //mlÛ¶vÛ¶
  int a,b,c;
  //aÔbP¿cÊ
  bool f;
  while(std::cin>>n && n){
     m.clear();
     v.clear();
     f=true;
    for(;n;n--){
      std::cin>>a>>b>>c;
      if(!m[a])v.push_back(a);
      m[a]+=b*c;
    }
    
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>=1000000){
	f=false;
	std::cout<<v[i]<<std::endl;}
    }
    if(f)std::cout<<"NA"<<std::endl;
  }
  return 0;
}

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


int main(){
	int uriage[4000][2],n,no,tanka,su,i,j,newflag,naflag;
	
	while(0<=scanf("%d",&n)){
		if(n==0) break;
		memset(uriage,-1,sizeof(uriage));
		for(i=0;i<n;i++){
			scanf("%d%d%d",&no,&tanka,&su);
			newflag=0;
			for(j=0;j<n;j++){
				if(uriage[j][0]==no){
					uriage[j][1]+=tanka*su;
					newflag=1;
					break;
				}
			}
			if(newflag==0){
				for(j=0;j<n;j++){
					if(uriage[j][0]==0){
						uriage[j][1]+=tanka*su;
						uriage[j][0]=no;
						break;
					}
				}
			}
		}
		naflag=0;
		for(i=0;i<n;i++){
			if(uriage[i][0]==0)break;
			if(uriage[i][1]>=1000000){
				printf("%d\n",uriage[i][0]);
				naflag=1;
			}
		}
		if(naflag==0)printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>

int main()
{
    bool loop = true;

    while (loop) {
        int dataset_num;
        int count = 0;
        std::cin >> dataset_num;

        if (dataset_num == 0) {
            loop = false;
            break;
        }

        for (int i = 0; i < dataset_num; i++) {
            int officer_num;
            int price;
            int figure;
            std::cin >> officer_num;
            std::cin >> price;
            std::cin >> figure;

            if (price * figure >= 1000000) {
                std::cout << officer_num;
                count +=1;
            }
        }
        if (count == 0) {
            std::cout << "NA" << std::endl;
        }
    }

    return 0;
}

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

int n;
pair<int, int> ans;

int solve(int n){
        int id,p,q,sales[10000]={};
        for(int i=0;i<n;i++){
                cin >> id;
                cin >> p;
                cin >> q;
                sales[id] += p*q;
        }
        ans.first = 0;
        ans.second = 0;
        for(int i=0;i<10000;i++){
                if(ans.second < sales[i]){
                        ans.first = i;
                        ans.second = sales[i];
                }
        }
        if(ans.second < 1000000){
                cout << "NA" << endl;
        }else {
                cout << ans.first << endl;
        }
}

int main(){
        while(1){
                cin >> n;
                if(n == 0) break;

                solve(n);
        }
}

C++: #include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

li shine[4040];

int main(){
	li n;
	while(1){
		cin>>n;
		if(n==0)break;
		rep(i,4040)shine[i]=0;
		rin{
			li a1,a2,a3;
			cin>>a1>>a2>>a3;
			shine[a1]+=a2*a3;
		}
		bool ita=false;
		rep(i,4040){
			if(shine[i]>=1000000){
				cout<<i<<endl;
				ita=true;
			}
		}

		if(!ita)puts("NA");
	}

	return 0;
}