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:
    flg = True
    inf = []
    dic = {}
    n = int(input())
    if n==0:
        break
    for i in range(n):
        inf.append(list(map(int,input().split())))
        if inf[i][0] in dic:
            tmp = dic[inf[i][0]] + inf[i][1]*inf[i][2]
            dic[inf[i][0]] = tmp
        else:
            dic[inf[i][0]] = inf[i][1]*inf[i][2]

    for shain_id,sale in dic.items():
        if sale >= 1000000:
            print(shain_id)
            flg = False
    if flg:
        print("NA")
        

    # for i in inf:

Python: while True:
    num = int(input())
    if not num: break
    result = {}
    for _ in range(num):
        x, y, z = [int(el) for el in input().split(' ')]
        if x in result:
            result[x] += y*z
        else:
            result[x] = y*z
    res = [print(k) for k,v in result.items() if v >= 1e6]
    if not res: print('NA')

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

import sys

while True:
    n = int(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: import sys
import math

data =[0 for i in range(4000)]
p_data = []
while True:
	n = int(input())
	count = 0
	if n == 0:
		break
	for i in range(n):
		e,p,q = map(int, input().split())
		data[e] = data[e] + p * q
		if p_data.count(e) == 0:
			p_data.append(e)
		if i >= 1:
			p_data.sort()
	for i in range(len(p_data)):
		if data[p_data[i]] >= 1000000:
			print(p_data[i])
			count = count + 1
			data[p_data[i]] = 0
		elif data[p_data[i]] != 0:
			data[p_data[i]] = 0
	if count == 0:
		print('NA')
	p_data.clear()

Python: import collections
while 1:
	li=collections.defaultdict(int)
	n=int(input())
	if n==0:
		break
	for i in range(n):
		(emp,prc,num)=list(map(int,input().split()))
		li[emp]+=prc*num
	tmp=True
	for i,j in li.items():
		if j>=1000000:
			print(i)
			tmp=False
	if tmp:
		print("NA")
	li.clear()

Python: data_num = int(input())

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\n")
        nice_syatiku += 1

if nice_syatiku == 0:
    print("NA\n")

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

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

def resetDataset():
    del employeeSalesList[0 : len(employeeSalesList) + 1]

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 printEmployeeOfDataset():
    answerList = [data[0] for data in employeeSalesList if data[1] >= 1000000]
    if len(answerList) == 0:
        print("NA")
    else:
        print("\n".join(map(str, answerList)))

resetDataset()
dataCount = readDataCount()
while dataCount > 0:
    for _ in range(dataCount):
        employeeId, price, volume = list(map(int, input().split(" ")))
        employeeSales = searchEmployeeSales(employeeId)
        employeeSales[1] += price * volume
    printEmployeeOfDataset()
    resetDataset()
    dataCount = readDataCount()

Python: from sys import stdin

if __name__ == '__main__':
    for line in stdin:
        if int(line) == 0:
            break

        isEmpty = True
        record = {}
        for _ in range(int(line)):
            employee = input().split(' ')
            total = int(employee[1]) * int(employee[2])

            if total >= 1000000:
                print(employee[0])
                isEmpty = False
            else:
                e_t = record.get(employee[0])

                if e_t:
                    e_t = record.get(employee[0]) + total
                    if e_t >= 1000000:
                        print(employee[0])
                        isEmpty = False
                    else:
                        record[employee[0]] = e_t

                else:
                    record[employee[0]] = total

        record.clear()

        if isEmpty:
            print('NA')

Python: import collections
while 1:
	li=collections.defaultdict(int)
	emplist=[]
	n=int(input())
	if n==0:
		break
	for i in range(n):
		(emp,prc,num)=list(map(int,input().split()))
		if emp not in emplist:
			emplist.append(emp)
		li[emp]+=prc*num
	tmp=True
	for i in emplist:
		if li[i]>=1000000:
			print(i)
			tmp=False
	if tmp:
		print("NA")
	li.clear()

Python: while True:
    try:
        n=int(input())
    except:
        break
    if n==0:
        break
    data=[]
    for i in range(n):
        spam=[x for x in map(int,input().split())]
        if spam[1]*spam[2]>=1000000:
            if (spam[0] in [b[0] for b in data])==False:
                data.append(spam)
    if len(data)==0:
        print('NA')
    else:
        for i in [b[0] for b in data]:
            print(i)

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)