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: data_num = 1

while(data_num != 0):

    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\n")

Python: while True:
	n=int(input())
	if n==0: break
	l=[]
	d={}
	for i in range(n):
		i,p,q=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: 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_] = 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')

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

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')