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: # coding: utf-8
# Here your code !

dataCount = int(input())
while dataCount > 0:
    employeeSalesList = []
    for _ in range(dataCount):
        dataList = input().split(" ")
        employeeId, price = int(dataList[0]), int(dataList[1]) * int(dataList[2])
        found = False
        for data in employeeSalesList:
            if data[0] == employeeId:
                data[1] += price
                found = True
        if not found:
            employeeSalesList.append([employeeId, price])

    answerList = [data[0] for data in employeeSalesList if data[1] >= 1000000]
    if answerList:
        print("\n".join(map(str, answerList)))
    else:
        print("NA")

    dataCount = int(input())

Python: while True:
	n = int(input())
	if n == 0:
		break
	else:
		greatworkers = []
		for i in range(n):
			person, price, number = [int(i) for i in input().split()]
			if price * number >= 1000000:
				greatworkers.append(str(person))
		if greatworkers == []:
			print('NA')
		else:
			print('\n'.join(greatworkers))

Python: # -*- coding: utf-8 -*-

import sys

while True:
    n = int(input())
    j = 0
    if n == 0:
        break
    salesmap = [0 for i in range(0,4001)]
    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 not n:
    break
  
  dic = {}

  for i in range(n):
    e, p, q = map(int, input().split())    
    if e in dic:
      dic[e] = (dic[e][0], dic[e][1] + p * q)
    else:
      dic[e] = (i, p * q)

  lst = []

  for k in dic:
    if dic[k][1] >= 1000000:
      lst.append((dic[k][0], k))
  
  lst.sort()

  if lst:
    for e in lst:
      print(e[1])
  else:
    print("NA")

Python: datasets=[]
while True:

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

  inputs=[None]*n
  for t in range(0,n):
    inputs[t] = list(map(int,input().split()))
    #inputs == [[i0,p0,q0],[i1,p1,q1],[i2,p2,q2]]

  id_sale = [] # id_sale == [id,sale,id,sale,id,sale]
  for i in inputs: # i == [ik,pk,qk]
    try:
      id_sale[id_sale.index(i[0])+1] += i[1]*i[2]
    except ValueError:
      # output in the order of inputting
      # (list1 += list2) == [list1_elements, list2_elements]
      id_sale += [i[0],i[1]*i[2]]

  na=True
  for i in range(0,len(id_sale),2):
    if id_sale[i+1] >= 1000000:
      print(id_sale[i])
      na=False
  if na:
    print("NA")

Python: while True:
    str = input().split()
    if len(str) == 1 and not str == "0":
        datadic={}
        nn = len(str)
        for ii in range(nn):
            data = input().split()
            datadic[data[0]] = int(data[1]) * int(data[2])
        print(datadic[ max( datadic.values() ) ])
    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]:break
    shain = [[x[0], x[1]*x[2]] for x in d[1:]]
    #score = [ 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: lib = [0] * 4000

while True:
    a = int(input())
    if a == 0:
        break
    
    for _ in range(a):
        s,m,l = map(int, input().split())
        lib[s-1] +=  m*l
    
    if max(lib) <1000000:
        print("NA")
    else:
        for i in range(4000):
            if lib[i] >= 1000000:
                print(i+1)
    for i in range(4000):
        lib[i] = 0

Python: while True:
  N = input()
  if not N:
    break
  m = dict()
  o = []
  for i in range(N):
    a, b, c = map(int, raw_input().split())
    o.append(a)
    m[a] = (m[a] if a in m else 0) + b * c
  for i in set(o):
    if m[i] >= 1000000:
      print(i)
  if max(m.values()) < 1000000:
    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 f:
        print("NA")

Python: 


while True:
    n=int(input())
    if n==0:
        break
    else:
        for i in range(n):
            k=0
            l=map(int, input().split())
            if l[1]*l[2]>=1000000:
                print(l[0])
                k+=1
        if k==0:
            print("NA")

Python: # -*- coding: utf-8 -*-

import sys

while True:
    n = int(input())
    j = 0
    if n == 0:
        break
    salesmap = [0 in range(0,4001)]
    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: #!/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]:break
    shain = [[x[0], x[1]*x[2]] for x in d[1:]]
    #score = [ 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: if __name__ == '__main__':

	while True:
		try:
			n = int(input())
			if n == 0:
				break

			no = []
			total = []
			for i in range(n):
				e,p,q = map(int,input().split())

				if e not in no:
					no.append(e)
					total.append(p*q)
				else:
					ind = no.index(e)
					total[ind] += p*q

			cnt = 0
			for j,k in enumerate(total):
				if k >= 1000000:
					cnt += 1
					print(no[j])
			if cnt == 0:
				print("NA")

		except EOFError:
			break

Python: while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [input().split() for i in range(n)]:
    d=int(b)*int(c)
    if a in L:
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a]>=1e6:print(a);f=0
  if f:print('NA')

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