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: n = int(input())
while n != 0:
    score = {}
    j = 0
    for i in range(n):
        e,p,q = list(map(int,input().split()))
        if e in score:
            score[e]["value"] += p*q
        else:
            score[e] = {"value":p*q, "index":j}
            j += 1
    f = {}
    for e,v in score.items():
        if v["value"] >= 1000000:
            f[v["index"]] = e
    if len(f)==0:
        print("NA")
    else:
        for w in sorted(f.items(), key = lambda x:x[0]):
            print(w[1])
    n = int(input())

Python: while True:
    no = {}
    n = int(input())
    if (n == 0):
        break
    
    for i in range(n):
        datas = map(int, input().split())
        li = list(datas) 
        e = li[0]
        p = li[1]
        q = li[2]

        s = p * q
        if (e not in no):
            no[e] = s
        else:
            no[e] += s

    na = True    
    for k in no.keys():
        if (1000000 <= no[k]):
            print(k)
            na = False
    
    if (na == True):
        print("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(),reverse=True):
            if v >= 1000000:
                print("%d" %(k))
                cnt += 1
            else:
                pass

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

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=jp
"""
import sys


def solve(data):
    result = []
    total_sales = [0 for _ in range(4002)]
    for id, unit_price, quantity in data:
        total_sales[id] += unit_price * quantity
    for i, sales in enumerate(total_sales):
        if sales >= 1000000:
            result.append(i)
    return result


def main(args):
    #data = []
    #data.append([1001, 2000, 520])
    #data.append([1002, 1800, 450])
    #data.append([1003, 1600, 625])
    #data.append([1001, 200, 1220])

    while True:
        num = int(input())
        if num == 0:
            break
        data = []
        for _ in range(num):
            data.append([int(x) for x in input().split(' ')])
        result = solve(data)
        if result:
            for ele in result:
                print(ele)
        else:
            print('NA')


if __name__ == '__main__':
    main(sys.argv[1:])

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

import sys

while True:
    n = 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: def parse(i):
    l = input().strip().split()
    return ((i, l[0]), int(l[1]) * int(l[2]))


n = int(input())

while n:
    ss, d = [parse(_) for _ in range(n)], {}

    for s in ss:
        k = s[0][1]
        d[k] = (d[k][0], d[k][1] + s[1]) if k in d else s

    d = [v[0] for v in d.values() if v[1] >= 1000000]

    if d:
        print('\n'.join(k[1] for k in sorted(d)))
    else:
        print('NA')

    n = int(input())

Python: while 1:
 a={};b=1
 n=int(input())
 if n==0:break
 for _ in[0]*n:
  e,p,q=map(int,input().split())
  a.setdefault(e,0);a[e]+=p*q
 for e in a:
  if a[e]>=1e6:print(e);b=0
 if b: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: 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]
    if i[0] in id_sale:
      id_sale[id_sale.index(i[0])+1] += i[1]*i[2]
    else:
      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 == True:
    print("NA")

Python: import numpy as np

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: # 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

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

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

for row in answerList:
    print(row)