Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

Python: while True:
    num = int(input())
    if not num:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    tmp = [i for i,j,k in data if j*k >= 1e6]
    seen = set()
    seen_add = seen.add
    result = [x for x in tmp if x not in seen and not seen_add(x)]
    if not result:
        print('NA')
    else:
        [print(r) for r in result]

Python: while True:
    num = int(input())
    if not num:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    tmp = [i for i,j,k in data if j*k >= 1e6]
    seen = set()
    seen_add = seen.add
    result = [x for x in tmp if x not in seen and not seen_add(x)]
    if not result:
        print('NA')
    else:
        [print(r) for r in result]

Python: while True:

    data_num = int(input())
    
    if data_num == 0:
        break

    nice_syatiku = 0

    for data_num in range(data_num):

        a,b,c = map(int,input().split())

        Earnings = b * c
        
        if Earnings >= 1000000:
            print(a)
            nice_syatiku += 1

    if nice_syatiku == 0:
        print("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')