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>

using namespace std;

typedef unsigned long long ll;

ll data[4001];
int status;

void print(){
  for(int i = 0; i < 4001; i++)
    if(data[i] >= 1000000){
      cout << i << endl;
      status = 0;
    }
}
int main(){
  ll in;
  while(cin >> in && in){
    status = 1;
    fill(data,data+4001,0);
    for(int i = 0; i < in; i++){
      ll num,p,q;
      cin >> num >> p >> q;
      if(data[num] < 1000000)data[num] += p*q;
    }
    print();
    if(status) cout << "NA" << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

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

    vector<int,int> data;
    for(int i = 0;i < n;++i){
      int num,sa,ko;
      cin>>num;
      cin>>sa;
      cin>>ko;

      data.push_back(make_pair(num,sa * ko));
    }

    for(pair<int,int> e : data){
      if(e.second >= 1000000){
        cout<<e.first<<endl;
      }
    }
  }

  return 0;
}

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

using namespace std;

int main(){
  int i, j, n, id, x, y;
  double sum;
  vector<int> data;

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

    for(i=0; i<n; ++i){
      cin >> id >> x >> y;
      sum = 0.000001 * (double)x * (double)y;
      if(sum >= 1.0) data.push_back(id);
    }

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

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

int main(){
    int n,i;
    while(cin>>n,n){
        map<int,long long>m;
        vector<int>vec;
        long long p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            if(!m[i])vec.push_back(i);
            m[i]+=p*q;
        }
//        for (map<int,long long>::iterator it=m.begin(); it!=m.end(); ++it){
//            if(it->second>=1000000){
//                s=1;
//                cout<<it->first<<endl;
//            }
//        }
        for (int i=0;i<vec.size();i++){
            map<int,long long>::iterator it=m.find(vec[i]);
            if(it->second>=1000000){
                s=1;
                cout<<it->first<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

C++: #include<stdio.h>
#include<memory.h>
int main(){
	int n,i,j,k,e[1000],p[1000],q[1000];
	int c[1000],count=0,count2=0;
	int gokei=0;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&e[i],&p[i],&q[i]);
			gokei=p[i]*q[i];
			for(j=0;j<i;j++){
				if(e[i]==e[j]){
					gokei+=p[j]*q[j];
				}
			}
			for(k=0;k<count;k++){
				if(e[i]==c[k]){
					goto a;
				}
			}
			if(gokei>=1000000){
				c[count]=e[i];
				count++;
			}
			a:
			gokei=0;
		}
		for(i=0;i<count;i++){
			printf("%d\n",c[i]);
		}
		if(count==0){
			printf("NA\n");
		}
		count=0;
		memset(c,0,sizeof(c));
	}
	
	return 0;
}

C++: #include <stdio.h>
 
 

 
int main(void){
	int i,j,k;
	int n,num[4000];
	long long int tanka[4000],sale_num[4000],sale_all[4001];
	bool judge[4001];
	
	while(scanf("%d",&n),n){[
		k=0;
		for(j=0;j<=4001;j++){
			judge[j]=0;
			sale_all[j]=0;
		}
		
		for(i=0;i<n;i++){
			scanf("%d%lld%lld",&num[i],&tanka[i],&sale_num[i]);
		}
		
		//初期化

		
		//idに対応したsaleに+
		for(i=0;i<n;i++){
			sale_all[num[i]] = sale_all[num[i]] + tanka[i]*sale_num[i];
		}
		
		for(i=0;i<n;i++){
			if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
				printf("%d\n",num[i]);
				judge[num[i]]=1;
				k=1;
			}
		}
		
		if(k!=1)printf("NA\n");
	}
	
	return 0;
}

C++: #include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;
 
int n;
 
int main(){
	while(scanf("%d", &n),n){
		vector<P> vec;
		for(int i = 0; i < n; i++){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			bool ok = true;
			for(int j = 0; j < vec.size(); j++){
				if(vec[j].first == x){
					vec[j].second += p*q;
					ok = false;
					break;
				}
			}
			if(ok) vec.push_back(P(x,p*q));
		}
		bool ok = true;
		for(int i = 0; i < vec.size(); i++){
			if(vec[i].second >= 1000000){
				ok = false;
				printf("%d\n", vec[i].first);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	int n;
	int a,b,c,d;
	int num[4001],tan[4001],ans[4001];
	bool flag=false;
	while(1){
		for(a=0;a<=4000;a++){
			num[a]=0;
			tan[a]=0;
			ans[a]=0;
		}
		flag=false;
		cin >> n;
		if(n==0)break;
		for(a=0;a<n;a++){
			cin >> b >> c >> d;
			num[b]+=c,tan[b]+=d;
		}
		for(a=1;a<=4000;a++){
			if(num[a]*tan[a]>=1000000)printf("%d\n",a),flag=true;
		}
		if(flag==false)printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int N; cin >> N, N;) {
		vector<ll> shine(4001, 0LL);
		queue<int> idx;
		rep(i,N) {
			int num;
			ll a, b;
			cin >> num >> a >> b;
			if(shine[num] == 0) {
				shine[num] = a * b;
				idx.push(num);
			} else {
				shine[num] += a * b;
			}
		}
		bool f = false;
		while(!idx.empty()) {
			int t = idx.front(); idx.pop();
			if(shine[t] >= 1000000LL) {
				cout << t << endl;
				f = true;
			}
		}
		if(!f) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<stdio.h>

int main(void)
{
	struct employee
	{
		int N,P,A;
	};
	employee person[4000];
	int a,b=0,c;
	for(;;b=0)
	{
		scanf("%d",&c);
		if(c==0)
			break;
		for(a=0;a<c;a++)
			scanf("%d %d %d",&person[a].N,&person[a].P,&person[a].A);
		for(a=0;a<c;a++)
		{
			if(person[a].P*person[a].A>=1000000 )
			{
				printf("%d\n",person[a].N);
				b++;
			}
		}
		if(b==0)
			printf("NA\n");
	}
}