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 ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<ll,ll> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b,c;
  while(cin >> n && n){
    vector<pair<ll,ll>> v;
    vary(ll,v2,4001,0);
    vary(ll,t,4001,0);
    ll cnt=0;
    rep(i,n){
      cin >> a >> b >> c;
      if(v2[a] == 0){
        v.push_back(make_pair(cnt,a));
        ++cnt;
        v2[a] = 1;
      }
      t[a] += b * c;
    }
    bool f = false;
    REP(i,0,v.size()){
      if(t[v[i].se] >= 1000000){
        cout << v[i].se<<endl;
        f = true;
      }
    }
    if(!f) cout << "NA"<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,ban,tanka,kazu,i,j,x={0};
	bool y={false};
	for(j=0;j<50;j++){
	cin>>n;
	if(n==0){
	break;
	}
	for(i=0;i<n;i++){
	cin>>ban>>tanka>>kazu;
	if(tanka*kazu>=1000000){
	cout<<ban<<endl;
	y=true;
	x+=ban;
	}
	}
	if(y==false){
	cout<<"NA"<<endl;
	}
	y=false;
	}
return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void) {

	int n, e[1000], p[1000], q[1000];
	int cnt = 0;

	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> e[i] >> p[i] >> q[i];
			if (p[i] * q[i] >= 1000000)
				cout << e[i] << endl;
			else
				cnt++;
		}
		if (cnt == n)
			cout << "NA" << endl;
		cnt = 0;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


typedef int ll;


using namespace std;

int main()
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0) break;

		vector<int> order;
		map<int, ll> sale;
		for (int i = 0; i < n; ++i)
		{
			int no, value, num;
			scanf("%d %d %d", &no, &value, &num);
			if (sale.count(no) == 0)
			{
				sale.insert(make_pair(no, 0));
				order.push_back(no);
			}
			ll t = (ll)value * num;
			sale[no] += t;
		}
		bool any = false;
		for (int i = 0; i < order.size(); ++i)
		{
			if (sale[order[i]] >= 1000000)
			{
				printf("%d\n", order[i]);
				any = true;
			}
		}
		if (!any)
			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<int> shine(4001, 0);
		queue<int> idx;
		rep(i,N) {
			int num, 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] >= 1000000) {
				cout << t << endl;
				f = true;
			}
		}
		if(!f) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n)
	{
		if(!n) break;

		bool f = true;
		rep(i, n)
		{
			int a, s, num;
			cin >> num >> a >> s;

			if(1000000 <= a * s)
			{
				f = false;
				cout << num << endl;
			}
		}
		if(f) cout << "NA" << endl;
	}
}

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

std::vector<std::string> split(const std::string& ref,char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num=0;
std::string str;
std::vector<std::string> ref;
std::vector<std::string> res;

std::cin >> str;
if(str!="") it_num=std::stoi(str);
while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(std::cin,str);
ref=split(str,' ');
if((std::stoi(ref[1])*std::stoi(ref[2]))>=1000000){
res.push_back(ref[0]);
}
}
std::cin >> it_num;
}
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}

return 0;
}