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 <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {

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

        bool na = true;
        set<ll> st;
        map<ll, ll> mp;

        rep(k, n) {
            ll i, p, q;
            cin >> i >> p >> q;
            st.insert(i);
            mp[i] += p*q;
        }

        auto itr = st.begin();
        while (itr != st.end()) {
            if (mp[*itr] >= 1000000) {
                cout << *itr << endl;
                na = false;
            }
            itr++;
        }

        if (na) cout << "NA" << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
int main(){
	int n;
	while(1){
		std::cin>>n;
		if(n==0)break;
		bool f=false;
		std::vector<int> vec;
		for(int i=0;i<n;i++){
			int a,b,c;
			std::cin>>a>>b>>c;
			if(b*c>=1000000)vec.push_back(a);
		}
		if(vec.empty())std::cout<<"NA"<<std::endl;
		else{
			for(int i=0;i<vec.size();i++){
				std::cout<<vec[i]<<std::endl;
			}
		}
	}
	return 0;
}

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

int main(){

  int num, v, n, m, len, cnt;
  vector<long long> vc[2];

  while(cin >> n){
    if(n == 0) break;
    vc[0].clear();
    vc[1].clear();
    len = 0;

    for(int i=0; i<n; i++){
      cin >> num >> v >> m;
      for(int j=0; j<=len; j++){
        if(j == len){
          vc[0].push_back(num);
          vc[1].push_back(v * m);
          len++;
          break;
        }
        if(vc[0][j] == num){
          if(vc[1][j] < 1000000){
            vc[1][j] += v * m;
          }
          break;
        }
      }
    }
    
    cnt = 0;
    for(int i=0; i<len; i++){
      if(vc[1][i] >= 1000000){
        cout << vc[0][i] << endl;
        cnt++;
      }
    }
    if(cnt == 0) cout << "NA" << endl;

  }

  return 0;

}

C++: #include <iostream>
#include <map>
using namespace std;
int main (int argc, char const* argv[]) {
  int saler_number;
  while (true) {
    cin >> saler_number;
    if (saler_number == 0) break;
    map<int,long long> result;
    int id, price, num;
    for (int i = 0; i < saler_number; i += 1) {
      cin >> id >> price >> num;
      if (result.count(id) == 0) {
        result.insert(make_pair(id,price * num));
      } else {
        result[id] += price * num;
      }
    }
    //
    bool valid_NA = true;
    map<int,long long>::iterator it = result.begin();
    while (it != result.end()) {
      if (it->second >= 1000000) {
        cout << it->first << endl;
        valid_NA = false;
      }
      //cout << it->first << ":" << it->second << endl;
      it++;
    }
    if (valid_NA) cout << "NA" << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    pair<int, pair<int, long long> > es[4001];
    for (int i = 1; i <= 4000; i++) {
      es[i].first = 5000;
      es[i].second.first = i;
      es[i].second.second = 0;
    }
    for (int i = 0; i < n; i++) {
      int id;
      long long v, c;
      cin >> id >> v >> c;
      es[id].first = min(es[id].first, i);
      es[id].second.second += v * c;
    }
    sort(es+1, es+4001);
    bool f = false;
    for (int i = 1; i <= 4000; i++)
      if (es[i].second.second >= 1000000) {
        f = true;
        cout << es[i].second.first << endl;
      }
    if (!f)
      cout << "NA" << endl;
  }
}

C++: #include <stdio.h>

 int main(void)
{
	int data;
	int m,n;
	int number;
	long prise,value;

	long int  money[4000];



	while(1){
		
		for(n=0;n<4000;n++){
			money[n] = 0;
		}

		scanf("%d",&data);
		if(data == 0) break;

		for(n=0;n<data;n++){
			scanf("%d%d%d",&number,&prise,&value);
			money[number] += prise * value;
		}

		for(n=0;n<4000;n++){
			if(money[n] >= 1000000){
				printf("%d\n",n);
			}
		}
	}


	

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main(){
	while (1){
		queue<int> q;
		lint d[4010] = {};
		rep(i, 0, 4010){
			d[i] = -1;
		}
		int n;
		cin >> n;
		if (n == 0) break;
		int a, b, c;
		rep(i, 0, n){
			cin >> a >> b >> c;
			if (d[a] == -1){
				q.push(a);
				d[a] = 0;
			}
			d[a] += b*c;
		}
		int ct = 0;
		while (!q.empty()){
			int x = q.front(); q.pop();
			if (d[x] >= 1000000){
				o(x); ct++;
			}
		}
		if (ct == 0){
			o("NA");
		}
	}

}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

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

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct salary{
	int no;
	int sell;
};

int main() {
	
	int n;
	while(cin>>n,n){
		vector<salary> vs;
		REP(i, n){
			int no, sell_n, value;
			cin >> no >> sell_n >> value;
			bool b = false;
			REP(j, vs.size()){
				if (vs[j].no == no){
					b = true;
					vs[j].sell += sell_n*value;
				}
			}
			if (!b)vs.push_back({ no, sell_n*value });
		}
		bool b2 = false;
		REP(i, vs.size()){
			if (vs[i].sell >= 1000000){
				cout <<vs[i].no << endl;
				b2 = true;
			}
		}
		if (!b2)cout << "NA"<< endl;
	}
}