Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

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

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;
      if(p*c>=1000000)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 <stdio.h>

int main(void) {

  int n;

  int id,unit,amount;
  int answer[4000];

  int i,flag;
  int a;


  while(1) {

    scanf("%d",&n);

    if(n==0) break;

    flag=0;
    a=0;

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

      scanf("%d %d %d",&id,&unit,&amount);

      if(unit*amount>=1000000) {

	answer[a++]=id;

	flag=1;

      }

    }

    if(flag==0) printf("NA\n");

    else {

      for(i=0;i<a;i++) printf("%d\n",answer[i]);

    }

  }

  return 0;

}

C++: #include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(void){
    int i,l,k;
    int n;
    long long id,c,q;
    long long data_list[4001];
    int id_list[4001];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        k=0;
        memset(data_list,0,sizeof(data_list));
        memset(id_list,0,sizeof(id_list));
        for(l=0;l<n;l++){
            cin>>id>>c>>q;
            if(data_list[id]>=1000000)data_list[id]=1000000;
            else{
                data_list[id]+=(c*q);
            }
            id_flag=true;
            for(i=0;i<k+1;i++){
                if(id_list[i]==id){
                    id_flag=false;
                }
            }
            
            if(id_flag){
                id_list[k]=id;
            k++;
            }
        }
        na_flag=true;
        for(l=0;l<k;l++){
            if(data_list[id_list[l]]>=1000000){
                cout<<id_list[l]<<endl;
                na_flag=false;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define vint vector<int>


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

        bool f = false;
        rep(i,n) {
            ll a,b,c; cin>>a>>b>>c;
            if(b*c >= (ll)1e6){
                cout<<a<<endl;
                f = true;
            }
        }
        if(!f) cout<<"NA"<<endl;
    }

    return 0;
}

C++: #include<stdio.h>
int main(void){
	int n;
	int ban[4001],tan,suu;
	int bansum[4001],banf[4001],i;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=1;i<=4000;i++){
			bansum[i]=banf[i]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d",&ban[i],&tan,&suu);
			bansum[ban[i]]+=tan*suu;
		}
		int flg=0;
		for(i=0;i<n;i++){
			if(bansum[ban[i]]>=1000000 && banf[ban[i]]==0){
				printf("%d\n",ban[i]);
				banf[ban[i]]=1;
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

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

int main(void){
	int n,count=0;
	vector<int> vec1,vec2,vec3,vec4;
	//½l©
	cin >> n;
	//lªf[^üêéæÁ
	for(int i=0;i<n;i++){
		int j,m,l;
		cin >> j >> m >> l;
		vec1.push_back(j);
		vec2.push_back(m);
		vec3.push_back(l);
	}
	//ÊÌ\¦
	for(int i=0;i<n;i++){
		if(vec2[i]*vec3[i]>=1000000){
			cout << vec1[i] << endl;
			count++;
		}
	}
	if(count==0 and n != 0){
		cout << "NA" << endl;
	}
	
	return 0;
}

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

int main()
{
    int n;
    while(1)
    {
        long long record[4000]={};
        int cnt = 0;
        cin >> n;
        if(n == 0)
        {
            break;
        }
        for(int i=0; i<n; i++)
        {
            int id;
            long long p;
            long long q;
            cin >> id >> p >> q;
            record[id] += p * q;
        }
        for(int i=0; i<4000; i++)
        {
            if(record[i] >= 1000000)
            {
                cout << i << endl;
                cnt++;
            }
        }
        if(cnt == 0)
        {
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

int main() {
  int n;
  
  while(cin>>n, n) {
    map<int,int> mp;

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

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

using namespace std;

int n, e, p, q;
vector<int> v;

int main() {
  while(scanf("%d", &n), n) {
    v.clear();
    for(int i = 0; i < n; i++) {
      scanf("%d %d %d", &e, &p, &q);
      if(p * q >= 1e6) {
        v.push_back(e);
      }
    }
    if(!v.size()) printf("NA\n");
    else for (int x : v) printf("%d\n", x);
  }
}

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

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

int main(){
	int n;
	while( cin >> n, n ){
		long long emp[4001];
		vector<int> nums;
		bool exist = false;
		memset( emp, 0, sizeof(emp) );
		rep(i,n){
			int num;
			long long val, am;
			cin >> num >> val >> am;
			emp[num] += val*am;
			if( find(nums.begin(), nums.end(), num) == nums.end() ){
				nums.push_back(num);
			}
		}
		rep(i,nums.size()){
			if( emp[nums[i]] >= 1000000 ){
				exist = true;
				cout << nums[i] << endl;
			}
		}
		if(!exist){
			cout << "NA" << endl;
		}

	}
	return 0;
}

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

using namespace std;
class saleData
{
public:

	int hireNo;
	int saleValue = 0;

	void addSale(int value)
	{
		if(saleValue < 1000000)
		{
			saleValue += value;
		}
	}

	bool judge()
	{
		if(saleValue >= 1000000)
		{
			return true;
		}
		return false;
	}
};
int main()
{
	while(1)
	{
		int dataCount;
		cin >> dataCount;
		vector<saleData> vobj;

		if(dataCount == 0)
		{
			break;
		}
		bool dataFlag = false;
		for(int i = 0; i < dataCount; i++)
		{
			int hireNo;
			int price;
			int No;
			cin >> hireNo >> price >> No;

			for(int j = 0; j < vobj.size(); j++)
			{
				if(vobj.size() == 0)
				{
					break;
				}
				if(vobj[j].hireNo == hireNo)
				{
					vobj[j].addSale(price * No);
					dataFlag = true;
					break;
				}
			}
			if(dataFlag == false)
			{
				saleData sObj;
				sObj.hireNo = hireNo;
				sObj.addSale(price * No);
				vobj.push_back(sObj);
			}
		}
		dataFlag = false;
		for(int i = 0; i < vobj.size() ; i++)
		{
			if(vobj[i].judge() == true)
			{
				cout << vobj[i].hireNo << endl;
				dataFlag = true;
			}
		}
		if(dataFlag == false)
		{
			cout << "NA" << endl;
		}


	}



}