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 <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
map<int,ll> data;
int main(){
	int n;
	while(cin>>n,n){
		data.clear();
		std::vector<int> a;
		a.clear();
		rep(i, n){
			int e,c,s;
			cin>>e>>c>>s;
			if(!data[e]){
				a.push_back(e);
				
			}
			data[e]+=(c*s);
		}
		bool flag =false;
		for(int i =0;i < a.size();i++){
			if(data[a[i]]>= 1000000){
				cout <<a[i]<<endl;
				flag =true;
			}
		}
		if(!flag){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) {break;};
    int number[n], price[n], value[n];
    for (int i = 0; i < n; i++) {
      cin >> number[i] >> price[i] >> value[i];
    }
    int total[n],NA;
    for (int i = 0; i < n; i++) {
      total[n] = price[i] * value[i];
      if (total[n] >= 1000000) {
	cout << number[i] << endl;
	NA = 1;
      }
    }
    if (NA != 1) {
      cout << "NA" << endl;
    }
  }
  return 0;
}

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

int main(){
    int n;
    while( cin >> n ){
        if( !n ) break;
        vector< long long int > ls(4001, 0);
        bool NA = true;
        for(int i = 0; i < n; i++){
            int a, b, c;
            cin >> a >> b >> c;
            if( ls[a] >= 0 ){
                ls[a] += b*c;
                if( ls[a] >= 1000000){
                    cout << a << endl;
                    NA = false;
                    ls[a] = -1;
                }
            }
        }
        if( NA ) cout << "NA" << endl;
    }
    return 0;
}

C++: #include<stdio.h>

int main(){
  while(1){
    int i, n;
    int a, b, c;
    scanf("%d", &n);
    if(n!=0){
      int e[4001] ={};
      int flag = 0;
      for(i=0;i<n;i++){
	scanf("%d %d %d", &a, &b, &c);
	if(e[a]+b*c<=2147483647)
	  e[a]+=b*c;
	else
	  e[a]=2147483647;
      }
      for(i=0;i<4001;i++){
	if(e[i]>=1000000){
	  printf("%d\n", i);
	  flag++;
	}
      }
      if(flag==0)
	printf("NA\n");
    }
    else{
      break;
    }
  }
  return 0;
}

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

int main(){

	int N,Q;
	while(1){
	cin>>N;if(N==0)break;
	int n[4001][2]={};
	for(int i=0;i<N;i++){
		int x,y,z;
		cin>>x>>y>>z;
		n[x][0]+=y*z;
		if(n[x][1]==0)n[x][1]=i;
	
	}
	for(int i=0;i<4001;i++){
		for(int j=i;j>i;j--){
			if(n[j][1]<n[j-1][1]){
				int t=n[j][0];n[j-1][0];n[j-1][0]=t;
				int T=n[j][1];n[j-1][1];n[j-1][1]=T;
			}
		}
	}
	bool f=false;
	for(int i=0;i<4001;i++){
		if(n[i][0]>=1000000){cout<<i<<endl;f=true;}
	}
	if(f==false)cout<<"NA"<<endl;

	}
	return 0;
}

C++: using System;
using System.Collections.Generic;
class _0100
{
    public static void Main()
    {
        bool flag;
        string[] data;
        long sum, val;
        Dictionary<string, long> d = new Dictionary<string, long>();
        List<string> sortDKey;
        int n = int.Parse(Console.ReadLine());
        while (n != 0)
        {
            d.Clear();
            flag = false;
            for (int i = 0; i < n; i++)
            {
                data = Console.ReadLine().Split();
                sum = long.Parse(data[1]) * long.Parse(data[2]);
                if (d.TryGetValue(data[0], out val))
                {
                    d.Remove(data[0]);
                    d.Add(data[0], val + sum);
                }
                else d.Add(data[0], sum);
            }
            sortDKey = new List<string>(d.Keys);
            sortDKey.Sort();
            foreach (string k in sortDKey)
            {
                if(d[k] >= 1000000)
                {
                    flag = (!flag) ? true : flag;
                    Console.WriteLine(k);
                }
            }
            if (!flag) Console.WriteLine("NA");
            n = int.Parse(Console.ReadLine());
        }
    }
}

C++: #include <iostream>
#include <map>
using namespace std;
int main()
{
    int n;
    while(1)
    {
        cin>>n;if(!n)return 0;
        int count=0;
        map<int,long long> sl;
        for(int i=0;i<n;++i){
            int sn,t,v;
            cin>>sn>>t>>v;
            sl.insert(make_pair(sn,t*v));
        }
        map<int,long long>::iterator it=sl.begin();
        while(it!=sl.end())
        {
            if((*it).second>=1000000){cout<<(*it).first<<endl;++count;}
            ++it;
        }
        if(!count)cout<<"NA"<<endl;
    }
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		map<int, long long int>mp;
		vector<int>vs;
		for (int i = 0; i < N; ++i) {
			long long int a, b, c; cin >> a >> b >> c;
			mp[a] += b*c;
			if (find(vs.begin(), vs.end(), a) == vs.end())vs.emplace_back(a);
		}
		bool flag = false;
		for (auto v : vs) {
			if (mp[v] >= 1000000) {
				cout << v << endl;
				flag = true;
			}
		}
		if (!flag)cout << "NA" << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(all(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
typedef vector<int> Vi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int n;
  while( cin >> n, n ) {
    int a, b, c;
    map<int, int> m;
    bool flag = false;
    Rep(i, n) {
      cin >> a >> b >> c;
      m[a] += b * c;
    }

    for(map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
      if( it->second >= 1000000 ) {
	cout << it->first << endl;
	flag = true;
      }
    }

    if( !flag ) cout << "NA" << endl;
  }
}