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++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

bool same(vector<pair<int, ll> >& t, int num, ll p)
{
  bool ok = true;
  REP(i, t.size()){
    if (num == t[i].Fi){
      ok = false;
      t[i].Se += p;
      break;
    }
  }

  return ok;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while (cin >> n, n){
    vector<pair<int, ll> > table;
    REP(i, n){
      bool ok = true;
      int num, price, cnt;
      cin >> num >> price >> cnt;
      if (same(table, num, price * cnt)){
        table.pb(mp(num, price * cnt));
      }
    }
    bool only = true;
    REP(i, table.size()){
      if (table[i].Se >= 1e6){
        print(table[i].Fi);
        only = false;
      }
      //cout << table[i].Fi << " " << table[i].Se << endl;
    }
    if (only) print("NA");
  }

  return (0);
}

C++: #include<bits/stdc++.h>
#define int long long
using namespace std;
 
signed main(){
int a;
while(scanf("%lld",&a),a){
    unordered_map<int,int>c;
    for(int d=0;d<a;d++){int e,f,k;scanf("%lld%lld%lld",&e,&f,&k);c[e]+=f*k;}
    bool s=true;
    for(auto g=c.begin();g!=c.end();g++){
	if(g->second>=1000000){s=false;printf("%lld\n",g->first);}
	}
	if(s)printf("NA\n");
    }
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        bool flag=false;
        rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        if(b*c>=1000000){cout<<a<<endl;flag=true;}
        }
        if(!flag)cout<<"NA"<<endl;
    }
}

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

using namespace std;

int n;
long long id[4000];
long long value[4000];
long long number[4000];

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> id[i] >> value[i] >> number[i];
    }
    vector<long long> v;
    for(int i=0;i<n;i++){
        if(value[i]*number[i] >= 1000000 ){
            v.push_back(id[i]);
        }
    }
    for (vector<long long>::iterator it=v.begin();it!=v.end();++it){
        cout << *it << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(){
long long n,a,b,c,f,i,j,k,s[4001],aa[4001];
while(cin>>n){
if(n==0)break;
for(i=0;i<n;i++){s[i]=0;aa[i]=0;}
for(i=0;i<n;i++){
cin>>a>>b>>c;
k=i;
for(j=0;j<i;j++)if(a==aa[j]){k=j;break;}
aa[i]=a;
for(j=0;j<c;j++){
if(s[k]>=1000000)break;
s[k]+=b;
}
}
for(f=0,i=0;i<n;i++)
if(s[i]>=1000000){cout<<aa[i]<<endl;f=1;}
if(f==0)cout<<"NA"<<endl;
}
return 0;
}

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

int main(){

 long int n,i,j,cnt=0,tanka,kazu,sum[4002]={0};
  char syain[4000][5],*syokika="GO";

  while(1){

    scanf("%ld",&n);
    if(n==0){
      break;
    }

    for(i=0;i<n;i++){
      scanf("%s",syain[i]);
      scanf("%ld",&tanka);
      scanf("%ld",&kazu);
      sum[i]=tanka*kazu;
    
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(strcmp(syain[i],syain[j])==0 && i!=j){
	  sum[i]=sum[i]+sum[j];
	  sum[j]=0;
	  strcpy(syain[j],syokika);
	}
      }
    }

    for(i=0;i<n;i++){
      if(sum[i]>=1000000){
	cnt=1;
	printf("%s\n",syain[i]);
      }
    }
    if(cnt==0){
      printf("NA\n");
    }

    cnt=0;

  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	while (cin >> n)
	{	bool f = false;
		int e[4000], p[4000], q[4000], t[4000];
		for (int i = 0; i < n; i++)
		{
			cin >> e[i];
			cin >> p[i];
			cin >> q[i];
			t[i] = p[i] * q[i];
		}

		for (int a = 0; a < n; a++)
		{
			if (t[a] >= 1000000)
			{
				cout << e[a] << endl;
				f = true;
			}
		
		
		}
		if (!f)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n;
    while(cin>>n){
    if(n==0)return 0;
    bool f=true;
    rep(i,0,n){
        int num;
        ll a,b;
        scanf("%d %lld %lld",&num,&a,&b);
        if(a*b>=1000000){
            printf("%lld\n",num);
            if(f)f=false;   
        }
    }
    if(f)cout<<"NA"<<endl;
    }
    
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<map>
using namespace std;
main(){
  //mlÛ¶vÛ¶
  long long a,b,c,n,f;
  //aÔbP¿cÊ
  while(cin>>n,n){
		map<int,long long> m;
		vector<int> v;
		f=1;
    for(;n;n--){
			cin>>a>>b>>c
      if(!m[a])v.push_back(a);
      m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++)if(m[v[i]]>999999)f=0;cout<<v[i]<<endl;
    if(f)cout<<"NA"<<endl;
  }
}