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):
    n = int(input())
    if n==0: break
    d = dict()
    s = set()
    c = 0
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in s:
            d[id_] += p*q
        else:
            s.add(id_)
            d[id_] = p*q
    for i in s:
        if d[i] >= 1000000:
            print(i)
            c+=1
    if c == 0: print('NA')

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: 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 == 0:
        break
    d = dict()
    for _ in range(n):
        i, p, q = map(int, input().split())
        d[i] = d[i]+p*q if i in d else p*q
    tmp = sorted(d.items(), key=lambda x: x[0])
    tmp = list(filter(lambda x: x[1] >= 1000000, tmp))
    if len(tmp):
        for t in tmp:
            print(t[0])
    else:
        print("NA")

Python: class Employee():
    def __init__(self,id,p,q):
        self.id = id
        self.total = p*q
    
    def add_total(self,total):
        self.total += total

class Manager():
    def __init__(self):
        self.employees = list()
        self.count = 0
    
    def add(self,e):
        if len(self.employees) == 0:
            self.employees.append(e)
        else:
            if self.employees[-1].id == e.id:
                self.employees[-1].add_total(e.total)
            else:
                self.employees.append(e)
            
    def pprint(self):
        for i,e in enumerate(self.employees):
            if e.total >= 1000000:
                print(e.id)
                self.count+=1
        if self.count == 0:
            print("NA")

def main():
    while(True):
        m = Manager()
        n = int(input())
        if n==0:
            break
        l = list()
        for i in range(n):
            s = list(map(int,input().split()))
            l.append(s)
        l = sorted(l)
        for x in l:
            m.add(Employee(*x))
        m.pprint()
    

if __name__=="__main__":
    main()

Python: while True:
    num=int(input())
    if num==0:
        break
    else:
        li=[]
        d={}
        for i in range (num):
            info=list(map(int,input().split()))
            try:
                d[info[0]]+=info[1]*info[2]
            except:
                d[info[0]]=info[1]*info[2]
                li.append(info[0])
    answer=[]
    for i in li:
        if d[i] >=1000000:
            answer.append(i)
    if answer==[]:
        print("NA")
    else:
        for i in answer:
            print(i)

Python: while True:
    n = int(input())
    if n == 0: break
  
    data = {}
    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]
  
    if max(data.values()) < 1000000:
        print('NA')
    else:
        for k,v in data.items():
            if v >= 1000000:
                print(k)

Python: while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(str, input().split()))
        ID = int(ipq[0])
        pq = int(ipq[1]) * int(ipq[2])
        if ID in sales:
            sales[ID] += pq
        else:
            sales[ID] = pq
    t = -1
    for k, v in sales.items():
        if v >= 1000000:
            print(k)
            t = 1
    if t == -1:
        print("NA")

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 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: l = int(input())
while l != 0:
	k = 0
	for l in range(0,l):
		li = input().split()
		if int(li[1]) * int(li[2]) >= 10**6:
			print(li[0])
			k = 1
	
	if k == 0:
		print("NA")
	l = int(input())

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: 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: from pip._vendor.distlib.compat import raw_input
while True:
    n = int(raw_input())
    if n == 0: break
    data = {}
    order = []
    for i in range(n):
        id,price,quant = map(int, raw_input().split())
        if id in data:
            data[id] += price * quant
        else:
            data[id] = price * quant
            order.append(id)

    if max(data.values()) < 1000000: print("NA")
    else:
        for i in order:
            if data[i] >= 1000000:
                print(id)