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: while True:
    n = int(input())
    if n != 0:
        dic = {}
        initno,initprice,initsales = map(int,input().split(" "))
        total = initsales*initprice
        dic[initno] = total
        for i in range(n-1):
            no, price, sales = map(int, input().split(" "))
            for k,v in dic.items():
                if k == no:
                    dic[no] = total
                    dic[no] = total + price*sales
                    break
                else:
                    dic[no] = price*sales
                    break
        cnt = 0
        for k,v in sorted(dic.items()):
            if v >= 1000000:
                print("%s" %(k))
                cnt += 1
            else:
                pass

        if cnt == 0:
            print("NA")
    else:
        break

Python: while True:
	n = int(input())
	if n == 0:
		break
	workers = {}
	workernames = []
	greatworkers = 0
	for i in range(n):
		person, price, number = map(int, input().split())
		if person in workers:
			workers[person] += price * number
		else:
			workers[person] = price * number
			workernames.append(person)
	for worker in workernames:
		if workers[worker] >= 1000000:
			print(worker)
			greatworkers += 1	
	if greatworkers == 0:
		print('NA')

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

    data={}
    staff=[]
    for i in range(n):
        tmp=list(map(int,input().split(' ')))
        if tmp[0] in data:
            data[tmp[0]]+=tmp[1]*tmp[2]
        else:
            data[tmp[0]]=tmp[1]*tmp[2]
            staff.append(tmp[0])

        if max(data.values())<1000000:
            print('NA')
        else:
            for k in staff:
                if data[k]>=1000000:
                    print(k)

Python: while True:
    n = int(input())
    if n == 0: break
  
    data = {}
    staff = []
    for i in range(n):
        tmp = [int(el) for el in input().split(' ')]
        if tmp[0] in data:
            data[tmp[0]] += tmp[1] * tmp[2]
        else:
            data[tmp[0]] = tmp[1] * tmp[2]
            staff.append(tmp[0])
  
    if max(data.values()) < 1e6:
        print('NA')
    else:
        for k in staff:
            if data[k] >= 1e6:
                print(k)

Python: import sys
def func(num):
   dict = {}
   for i in range(len(num)):
       if num[i][0] not in dict.keys():
           dict[num[i][0]] = int(num[i][1]) * int(num[i][2])
       else:
           dict[num[i][0]] = dict[num[i][0]] + int(num[i][1]) * int(num[i][2])
   list = dict.keys()
   flag = 0
   for i in list:
       if dict[i] >= 1000000:
           print(i)
           flag = 1
   if flag == 0:
       print("NA")
flag = 0
count = 0
n = 0
num = []
for line in sys.stdin.readlines():
   if flag == 0:
       n = int(line)
       if n == 0:
           break
       flag = 1
       count = 0
   elif flag == 1:
       count += 1
       num.append(line.split())
       if count == n:
           flag = 0
           func(num)
           del(num)
           num = []

Python: # coding: utf-8
# Here your code !
employeeSalesList = []

def resetDataset():
    for count in range(len(employeeSalesList)):
        employeeSalesList.pop(0)

def readDataCount():
    return int(input())

def searchEmployeeSales(employeeId):
    for data in employeeSalesList:
        if data[0] == employeeId:
            return data
    
    newData = [employeeId, 0]
    employeeSalesList.append(newData)
    return newData

def checkSales():
    employeeId, price, volume = list(map(int, input().split(" ")))
    employeeSales = searchEmployeeSales(employeeId)
    employeeSales[1] += price * volume

def printEmployeeOfDataset():
    found = False
    for data in employeeSalesList:
        if data[1] >= 1000000:
            print(data[0])
            found = True
    if not found:
        print("NA")

resetDataset()
dataCount = readDataCount()
while dataCount > 0:
    for _ in range(dataCount):
        checkSales()
    printEmployeeOfDataset()
    resetDataset()
    dataCount = readDataCount()

Python: n = int(input())
while n != 0:
	earnings = []
	for i in range(0,n):
		a = str.split(input(),' ')
		if i > 0 :
			for j in range(0,len(earnings)):
				if a[0] == earnings[j][0]:
					earnings[j][1] = str(int(earnings[j][1])+(int(a[1])*int(a[2])))
					break
				if j == len(earnings) - 1:earnings.append([a[0],str(int(a[1])*int(a[2]))])
		else:earnings.append([a[0],str(int(a[1])*int(a[2]))])
	milionear = []
	for i in range(0,len(earnings)):
		if int(earnings[i][1]) >= 1e6:
			milionear.append(earnings[i][0])
	if len(milionear) == 0 : print('NA')
	else:
		for i in range(0,len(milionear)):
			print(milionear[i])
	n = int(input())

Python: while True:
	n=int(input())
	if n:
		f=True
		a=[list(map(int,input().split())) for _ in range(n)]
		for i in range(n):
			if a[i][1]*a[i][2]>=1000000:
				print(a[i][0])
				f=False
		if f:
			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]: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: while True:
    num = int(input())
    if not num:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    result = [print(i) for i,j,k in data if j*k >= 1e6]
    if not result:
        print('NA')

Python: import sys
 
while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break
    members = []
    sales  = {}
    for i in range(n):
        e,p,q = sys.stdin.readline().rstrip().split(' ')
        if not e in members:
            members.append(e)
            sales[e] = 0
        sales[e] += int(p) * int(q)
    ret = [member for member in members if sales[member] >= 1000000]
    if len(ret) != 0:
        for d in ret:
            print(d)
    else:
        print("NA")

Python: while True:
    n = int(input())
    if n == 0: break
    personel = {}
    for _ in range(n):
        e, p, q = input().split()
        if e in personel.keys():
            personel[e] += int(p) * int(q)
        else:
            personel[e] = int(p) * int(q)
    result = []
    for key, val in personel.items():
        if val >= 1000000:
            result.append(key)
    if not result:
        print('NA')
    else:
        print('\n'.join(result))

Python: while True:
    num = int(input())
    if not num:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    result = [print(i) for i,j,k in data if j*k >= 1e6]
    if not result:
        print('NA')