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")
		}
	}
}

Python: l = int(input())
while l != 0:
	k = 0
	A = []
	B = []
	for l in range(0,l):
		li = input().split()
		if li[0] in A:
			i = A.index(li[0])
			B[i] = B[i] + (int(li[1]) * int(li[2]))
		else:
			A.append(li[0])
			B.append(int(li[1]) * int(li[2]))
	for j,b in enumerate(B):
		if b >= 10**6:
			print(A[j])
			k = 1
		
	if k == 0:
		print("NA")
	l = int(input())

Python: while True:
    try:
        N=int(input())
        if N==0:break
        ans=[]
        dic={}
        for i in range(N):
            e,p,q=map(int,input().split())
            if e in dic:dic[e] +=p*q
            else:dic[e]=p*q
        for v,m in dic.items():
            if m>=1000000:ans.append(v)
        if len(ans)==0:ans.append("NA")
        for k in ans:
            print(k)
    except:break

Python: # Aizu Problem 0100: Sale Result
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    N = int(input())
    if N == 0:
        break
    sales = {}
    good = False
    order = []
    for n in range(N):
        i, p, q = [int(_) for _ in input().split()]
        if i not in order:
            order.append(i)
        sales[i] = sales.get(i, 0) + p * q
    good = False
    for i in order:
        if sales[i] >= 1000000:
            print(i)
            good = True
    if not good:
        print("NA")

Python: while True:
	n=int(input())
	if n==0: break
	l=[]
	d={}
	for _ in range(n):
		a,b,c=list(map(int,input().split()))
		if a in d:
			d[a]+=b*c
		else:
			d[a]=b*c
			l.append(a)
	if max(d.values())<1000000:
		print("NA")
	else:
		for k in l:
			if d[k]>=1000000:
				print(k)

Python: import sys

while True:
    n = input()
    salesmap = {}
    j = 0
    for i in range(1,4001):
    	salesmap[i] = 0
    if n == 0:
        break
    for i in range(n):
    	a = input().split()
    	salesmap[int(a[0])] += int(a[1])*int(a[2])
    for i in range(1,4001):
    	if salesmap[i] >= 1000000:
    		j += 1
    		print(i)
    if j == 0:
    	print('NA')
#print a # [a1, a2, a3, ..., aN]

Python: while True:
  n = int(input())
  if n == 0:
    break
  c = 0
  d = {}
  for i in range(n):
    num,x,y = map(int,input().split())
    if num in d:
      d[num] = d[num] + x*y
    else:
      d[num] = x*y
  for i in d:
    if d[i] >= 1000000:
      print(i)
      c += 1
  if c == 0:
    print('NA')

Python: from collections import defaultdict as dd
while True:
    n=int(input())
    if n==0:
        break
    data=dd(int)
    for i in range(n):
        a,b,c=map(int,input().split())
        data[a]+=b*c
    f=False
    for i,j in data.items():
        if j>=1000000:
            print(i)
            f=True
    if not f:
        print("NA")

Python: num=int(input())
emp=[]
cnt=0
for i in range(num):
    emp.append(num)
    emp[i]=[int(k) for k in input().split()]
for i in range(num):
    for q in range(i+1,num):
        if emp[i][0]==emp[q][0]:
            emp[i][1]=emp[i][1]+emp[q][1]
            emp[i][2]=emp[i][2]+emp[q][2]
            emp[q][1],emp[q][2]=0,0
    if emp[i][1]*emp[i][2]>=1000000:
        print(emp[i][0])
        cnt+=1
if cnt==0:
    print('NA')

Python: while True:
	n=int(input())
	if n==0: break
	d={}
	for i in range(n):
		a,b,c=list(map(int,input().split()))
		if a in d:
			d[a]+=b*c
		else:
			d[a]=b*c
	if max(d.values())<1000000:
		print("NA")
	else:
		for k in d.keys():
			if d[k]>=1000000:
				print(k)

Python: #個数の入力値が0になるまで繰り返す。空の辞書を作成。
while True:
    n = int(input())
    if n == 0:break
    sya = {}
    
    #辞書の中に社員番号があったなら数値を加算し、ないなら新しく追加する。
    for _ in range(n):
        try:
            a,b,c = map(int,input().split())
            sya[a] = sya[a]+b*c
        except KeyError:
            sya[a] = b*c
    k =[]
    
    #1,000,000以上の売り上げを出した社員番号を出力し、ないならNAを出力する。
    for i in sya:
        if sya[i] >= 1000000:print(i)
        k.append(sya[i] >= 1000000)
    if not any(k) == True:print("NA")

Python: import sys
while True:
    str = sys.stdin.readline().split()
    if len(str) == 1 and not str == "0":
        datadic={}
        nn = len(str)
        for ii in range(nn):
            data = sys.stdin.readline().split()
            datadic[data[0]] = int(data[1]) * int(data[2])
        print(datadic[ max( datadic.values() ) ])
    else:
        break

Python: while True:
  n = int(input())
  if n == 0:
    break
  c = 0
  l = []
  d = {}
  for i in range(n):
    num,x,y = map(int,input().split())
    if num in d:
      d[num] = d[num] + x*y
    else:
      d[num] = x*y
      l.append(num)
  for i in l:
    if d[i] >= 1000000:
      print(i)
      c += 1
  if c == 0:
    print('NA')

Python: while True:
	n=int(input())
	if n:
		a=[list(map(int,input().split())) for _ in range(n)]
		d={}
		for i in range(n):
			if a[i][0] in d:
				d[a[i][0]]+=a[i][1]*a[i][2]
			else:
				d[a[i][0]]=a[i][1]*a[i][2]
		print(d)
		for k in d.keys():
			if d[k]>=1000000:
				print(k)
		if max(d.values())<1000000:
			print("NA")
	else:
		break

Python: #!/usr/bin/env python3
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
    else:dataset[cnt-1].append(list(map(int, i.split(' '))))
    
for d in dataset:
    if d == [0]:pass
    else:
        shain = [[x[0], x[1]*x[2]] for x in d[1:]]
        slist = []
        for s in shain:
            if not(s[0] in slist):slist.append(s[0])
        newslist = [[x, 0] for x in slist]
        score = []
        for s in shain:
            newslist[slist.index(s[0])][1] += s[1]
        
        flag = False
        for n in newslist:
            if n[1] >= 1000000:
                print(n[0])
                flag = True
    if not flag:print('NA')

Python: while(True):
    n = int(input())
    if n==0: break
    d = dict()
    s = set()
    c = 0
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in s:
            d[id_] += p*q
        else:
            s.add(id_)
            d[id_] = p*q
    for i in s:
        if d[i] >= 1000000:
            print(i)
            c+=1
    if c == 0: print("NA")

Python: import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break
    member = {}
    for i in range(n):
        e,p,q = sys.stdin.readline().rstrip().split(' ')
        if not e in member.keys():
            member[e] = 0
        member[e] += int(p) * int(q)
    ret = sorted(member.items(), key=lambda d: d[1])[::-1]
    ret = [k for k,v in ret if v >= 1000000]
    if len(ret) != 0:
        for d in ret:
            print(d)
    else:
        print("NA")

Python: x = 1
while x != 0:
    x = int(input().rstrip())
    frag = 0
    for j in range(x):
        A = input().rstrip().sprit()
        if int(A[1]) * int(A[2]) >= 1000000:
            print(A[0])
            flag = 1
    if flag == 0:
        print("NA")