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++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    map<int, int> t;
    while (n--) {
      int i, p, q;
      cin >> i >> p >> q;
      if (t.count(i))
        t[i] += p * q;
      else
        t[i] = p * q;
    }
    vi v;
    for (auto x : t) {
      if (x.se >= 1000000) v.pb(x.fi);
    }
    if (v.size()) {
      rep(i, v.size()) cout << v[i] << endl;
    } else {
      cout << "NA" << endl;
    }
  }
}

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

const int BORDER = 1000000;

int main()
{
	int n;

	while( cin >> n && n ){
		int id, unit, amount, cnt = 0;
		int* list = new int[ n ];
		for( int i = 0; i < n; ++i ){
			cin >> id >> unit >> amount;
			if( unit * amount >= BORDER ){
				list[ cnt ] = id;
				++cnt;
			}
		}
		if( cnt != 0 ){
			for( int i = 0; i < cnt; ++i ){
				cout << list[ i ] << endl;
			}
		}else{
			cout << "NA" << endl;
		}
		delete[] list;
	}

	return 0;
}

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

int main() {
	int n,id,i,k,f,a,b,da[4001],jun[4001],ch[4001];
	while (cin >> n) {
		if (n==0) break;
		memset(da,0,sizeof(da));
		memset(ch,0,sizeof(ch));
		k=0;
		for (i=0;i<n;i++) {
			cin >> id >> a >> b;
			da[id]+=a*b;
			if (ch[id]==0) { ch[id]=1; jun[k++]=id;} 
			}
		f=0;
		for (i=0;i<k;i++) if (da[jun[i]]>=1000000) { cout << jun[i] << endl; f=1; }
		if (f==0) cout << "NA" << endl;
	}
	return 0;
}

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

int main() {
	int n;

	while(cin >> n, n) {
		int ID, price, sale;
		int table[4096];
		bool flag = false;
		memset(table, 0, sizeof(table));
		for(int i = 0; i < n; i++) {
			cin >> ID >> price >> sale;
			table[ID] += price * sale;
		}

		for(int i = 0; i < 4096; i++) {
			if(table[i] >= 1000000) {
				cout << i << endl;
				flag = true;
			}
		}

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

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void){
	int data[4001];
	int n;
	while(1){
		cin>>n;
		if(n==0)break;
		for(int i=1;i<=4000;i++){
			data[i]=0;
		}
		for(int i=0;i<n;i++){
			int a,b,c;
			cin>>a>>b>>c;
			data[a]+=b*c;
		}
		bool f=false;
		for(int i=1;i<=4000;i++){
			if(data[i]>=1000000){
				cout<<i<<endl;
				f=true;
			}
		}
		if(!f)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<iostream>
using namespace std;
int main() {
	int ans[1111],n,an,ban[1111],ba;
	while (1) {
		cin >> n;
		if (n == 0) {
			goto x;
		}
		an = 0;
		ba = 0;
		for (int i = 1; i <= n; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			for (int z = 1; z <= an; z++) {
				if (ban[z] == a) {
					ans[z] = ans[z] + b * c;
					goto a;
				}
			}
			an = an + 1;
			ans[an] = b * c;
			ban[an] = a;
		a:;
		}
		int kk;
		kk = 0;
		for (int i = 1; i <= an; i++) {
			if (ans[i] >= 1000000) {
				cout << ban[i] << endl;
				kk = 1;
			}
		}
		if (kk == 1) {
			kk = 0;
		}
		else {
			cout << "NA" << endl;
		}
	}
x:;
}

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;

		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>
using namespace std;




int n;


void solve()
{
	bool ok=false;
	int total[4000];
	bool check[4000];
	memset(check,false,sizeof(check));
	memset(total,0,sizeof(total));
	for(int i=0;i<n;i++){
		int num,a,b;
		cin>>num>>a>>b;
		total[num]+=a*b;
		if(total[num]>=1000000 && !check[num]){
			cout<<num<<endl;
			check[num]=true;
			ok=true;
		}
	}
	if(!ok) cout<<"NA"<<endl;
}

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

C++: #include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;

int main() {
    for (;;) {
        int n;
        scanf("%d", &n);
        if (n == 0) return 0;
        int c = 0;
        rep (_, n) {
            int id, p, q;
            scanf("%d%d%d", &id, &p, &q);
            if ((Int)p*q >= 1000000) {
                printf("%d\n", id);
                c++;
            }
        }
        if (c == 0) puts("NA");
    }
    return 0;
}

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

int main() {
	long long e, p, q;
	int n;
	while (cin >> n, n) {
		long long number[4001] = {};
		for (int i = 0; i < n; i++) {
			cin >> e >> p >> q;
			number[e - 1] += p*q;
		}

		int x = 0;
		for (int i = 0; i < 4001; i++) {
			if (number[i] >= 1000000) {
				cout << i + 1 << endl;
				x++;
			}
		}
		if (x == 0) { cout << "NA" << endl; }
	}
	return 0;
}